I'm using Bluehost and do have access to SSH, thankfully. I've also set my PHP to 5.4 in the Control Panel settings. Now, here's the two big questions that I can't seem to grasp: how do I install Composer and furthermore, after installing Composer, how do I get the dependencies included?
In this case, I am attempting to use the official Tumblr PHP Library, which has dependencies -- all of which can be found on Packagist.
I've referred to this question in which the OP is using HostGator. I have attempted to install Composer in a similar fashion and have done so with seemingly successful results. The issue, however, is that I don't know where to install it on Bluehost so I now have Composer installed in several random places on the server simply because I don't know how to navigate to find where to put it in this shared space.
I know this is the issue (i.e. it's installed in the wrong place) because when I use the composer phar files and syntax to install the packages, I get errors saying the commands don't exist.
I really hate asking for hand-holding assistance, but if someone could walk me through the proper installation of Composer on a shared space and the proper installation of a Composer package from Packagist on the same shared space, it would be much appreciated. I've dug through the Composer documentation and can't seem to find a proper guide -- if one can even exist -- for this case. At this point, I'm wondering if it's going to be different for every web host.
Once you install composer as mentioned by KLVTZ. In the bluehost environment, use the php-cli instead of php.
php-cli composer.phar install
When installing composer, the biggest problem I ran into was that Bluehost's command line php was 5.2 and composer needs 5.3+.
Fortunately, Bluehost does give you access to 5.4. You can find it at
/ramdisk/php/54/bin/php54-cli
I ended up setting up an alias to call composer.phar using the above php command and it's worked great. You can see more details on how to install composer on bluehost.
You should probably not use Composer on the remote host, but instead install it on the local machine that is used to upload your project to Bluehost. There you can manage all the stuff that is needed to fetch the dependencies, which might include having the ZIP extension enabled or having a ZIP program available, having GIT or Mercurial installed if you have to grab a version from a branch, and so on.
All these dependencies of using Composer might not be available on that remote host, and frankly: You really do not want to install these development tools on a production machine anyway, I think. Any software that potentially helps an attacker shouldn't be present if it can be avoided.
The issue, however, is that I don't know where to install it on Bluehost...
In order to fix this problem, you need to figure out where exactly your project folder is. Composer needs to be installed in that folder. If you have access to a UNIX shell, I recommend that you change your directory to that project folder
cd $_SERVER['DOCUMENT_ROOT']/project_folder/
Generally, your remote server will follow the same file directory tree as that on your local machine. However, if you are unsure as to how your file structure may be organized, you can always print working directory of your local machine:
pwd
After you have successfully located the correct file path on your shared space, simply install composer:
curl -sS https://getcomposer.org/installer | php
This will report back something like:
All settings correct for using Composer
Downloading...
Composer successfully installed to: /var/www/my_project/composer.phar
Use it: php composer.phar
You now have access to your composer.phar in your project. Let me know if you need any further help.
One problem on Bluehost is that the php command on Bluehost does not execute php-cli. So I "bypass" that by having my own php script earlier in the PATH and then forwarding the arguments to php-cli. In the same process I made script named composer which calls php-cli composer.phar directly.
So, this setup has worked for me on Bluehost:
In ~/bin I have the composer.phar and two bash scripts called php and composer. In ~/.bash_profile I have prepended ~/bin to my PATH.
~/bin/php looks as follows:
#!/bin/bash
php-cli "$#"
~/bin/composerlooks as follows:
#!/bin/bash
php-cli ~/bin/composer.phar "$#"
And the additions to ~/.bash_profile are these:
PATH=$HOME/bin:$PATH
PATH=$PATH:$HOME/.composer/vendor/bin
export PATH
(I have also added ~/.composer/vendor/bin as can be seen, this is handy for global access for some composed applications (for me that is laravel)).
Remember to source ~/.bash_profile. (Or reconnect)
I think you should do something like this.
In console
echo $PATH
Use one of these pathes
mv composer.phar {selected path}/composer
chmod +x {selected path}/composer
Now you can simply call composer everywhere
If you have composer installed in your root directory (under public_html), might be something related to PHP version. As Bluehost when chosing PHP version "Be aware that this only modifies your ~/public_html/php.ini file. If you choose to use PHP 5.4, you'll want to make sure your crons use "/usr/php/54/usr/bin/php" instead, as otherwise it will use PHP 5.2."
So you can try with the command
/usr/php/54/usr/bin/php-cli composer.phar install
Related
I'm trying to deploy my PHP (CakePHP) application through Azure DevOps and install Composer dependencies in the build step of the pipeline, using a Windows hosted agent.
The composer install is failing because common PHP extensions (namely intl and fileinfo) are unavailable to the PHP executable running in the build. Once deployed, the Web App on Azure does have these extensions. The composer web app extension is installed on the actual app service on Azure and there is a composer.phar file in the root of the repository.
The step I'm trying to run is just php composer.phar install --no-scripts --no-interaction --optimize-autoloader.
The pipeline fails with this error, but I have no idea how to access the .ini file or provide any options.
To enable extensions, verify that they are enabled in your .ini files:
- C:\tools\php\php.ini
PHP_INI_SCAN_DIR can be set, but this 'php template' from DevOps wipes out any added configuration properties when a new deploy happens. This also seems to be a totally different PHP than what the App Service actually runs. I can make a new template for config options, but the PHP extension issue seems to still be there on the build step.
If anyone knows how to simply have composer install dependencies and have them included in the build artifact (.zip file) created, I would greatly appreciate it. Thank you!
As answered in the comment by Levi Lu-MSFT, I was able to modify the PHP configuration by adding a new build task using the Command Line task and entering:
echo extension=intl >> C:\tools\php\php.ini
echo extension=fileinfo >> C:\tools\php\php.ini
Adding quotes caused an issue, but without it seems to work.
This question is different from: https://stackoverflow.com/questions/36150377/missing-vendor-autoload-php
I want to contribute to phpmyadmin. I cloned the github repo in my machine using Github Desktop software. I copied the downloaded files in xampp so that I can run phpmyadmin. But when I launch the phpmyadmin page, this error occurs:
File ./vendor/autoload.php missing or not readable.
Most likely you did not run Composer to install library files.
Where can I get that file? I saw something that uses composer create-project command but I don't get that where should I type that command?
I also downloaded phpmyadmin from their website and copy pasted in xampp directory and it worked well. It didn't give any such error.
What should I do?
This changed as of v4.7.0
https://www.phpmyadmin.net/files/4.7.0/
Starting with this version, phpMyAdmin uses Composer to manage PHP library dependencies while under development.
Users downloading the official source distribution will not notice a difference, however users of the git repository
should refer to https://docs.phpmyadmin.net/en/latest/setup.html#installing-from-git for details.
Here's the change PR for those interested: github.com/phpmyadmin/phpmyadmin/pull/11976
When you download or clone phpMyadmin it's missing the vendor folder, which is installed by Composer.
Open the phpMyadmin folder and run the composer install command. This will download and install third party dependencies and generate the vendor/autoload.php file.
I have developed a cs cart add on, But when I make a zip of it and try to upload it from gui it gives wrong structure data
so after little research I got that, I have to follow some steps of given in following url.
https://github.com/cscart/sdk
But after successful installation of composer, When I run the command
cscart-sdk command:name
It gives me error
cscart-sdk is not recognized as an internal or external command
I am very new to cscart add-on development
There seems to be something wrong with your composer install, please follow this tutorial (this is where cscart also relates to)
Installation - Linux / Unix / OSX#
Downloading the Composer Executable#
Composer offers a convenient installer that you can execute directly from the commandline. Feel free to download this file or review it on GitHub if you wish to know more about the inner workings of the installer. The source is plain PHP.
There are in short, two ways to install Composer. Locally as part of your project, or globally as a system wide executable.
Locally#
Installing Composer locally is a matter of just running the installer in your project directory. See the Download page for instructions.
The installer will just check a few PHP settings and then download composer.phar to your working directory. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things.
Now just run php composer.phar in order to run Composer.
You can install Composer to a specific directory by using the --install-dir option and additionally (re)name it as well using the --filename option. When running the installer when following the Download page instructions add the following parameters:
php composer-setup.php --install-dir=bin --filename=composer
Now just run php bin/composer in order to run Composer.
Globally#
You can place the Composer PHAR anywhere you wish. If you put it in a directory that is part of your PATH, you can access it globally. On unixy systems you can even make it executable and invoke it without directly using the php interpreter.
After running the installer following the Download page instructions you can run this to move composer.phar to a directory that is in your path:
mv composer.phar /usr/local/bin/composer
Note: If the above fails due to permissions, you may need to run it again with sudo.
Note: On some versions of OSX the /usr directory does not exist by default. If you receive the error "/usr/local/bin/composer: No such file or directory" then you must create the directory manually before proceeding: mkdir -p /usr/local/bin.
Note: For information on changing your PATH, please read the Wikipedia article and/or use Google.
Now just run composer in order to run Composer instead of php composer.phar.
I don't know if this question has been asked, because searching finds results mostly about moving the libraries installation directory.
I have a globally installed composer command. Is there a way to run, for example, composer install in a different directory than current, i.e. to specify the directory in which I would like tu run the command?
E.g. being in /home/someuser, I would like to acquire the same result as in running composer install it inside /home/someuser/myproject. Of course, one way would be to simply change the current directory, run composer and go back.
Try composer install -h. There you'll find an option --working-dir (or -d). And that's what you're looking for.
Then run:
composer install --working-dir=/home/someuser/myproject
You can find more in composer docs.
Depending on your operating system, the = might need to be removed:
composer install --working-dir /home/someuser/myproject
In addition to the above answer from Tomáš Votruba i had to append the = charachter on OSX. So the full command would be:
composer install -d=/home/someuser/myproject
My first post on SO so was unable to simply add this as a comment.
This works for me, PHP 7.3 on ubuntu 18.04
Install
composer install --working-dir=/your_composer_dir
Update
composer update --working-dir=/your_composer_dir
I tried what others said, but it was giving me: Invalid working directory specified 'PATH' does not exist. Although it was my working dir that contained composer.json!
I don't know why anyway, but this worked for me (only for gnu/linux users):
composer --working-dir=$(pwd)
And by the way, if you had run composer -h, it would've told you the solution:
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
I am using a Windows machine with PHPStorm (terminal) and this worked for me.
composer install --working-dir /home/someuser/myproject
My Linux OS machines require me to use
composer install --working-dir=/home/someuser/myproject
Note: You may be able to substitute ~/ for /home/someuser/ if your path is super long.
Run:
cd /home/mysites/google.com
Then run:
composer require facebook/graph-sdk
Above steps will open up the directory named (google.com) and install facebook Graph SDK there.
Composer is a tool for dependency management in PHP projects. It allows you to declare the dependent libraries your project needs and it will install them in your project for you. Composer is not a package manager.
I told this to declare my meaning from Composer. Recently I have tried to run my first Google API project. There is a quickStart witch tells I need to use Composer. So I tried to run composer using php composer.phar install, but the only output I got was some question marks ???????, and no dependencies where fetched. I haven't noticed anything special about composer itself, it seems that there must be something with .phar files that I don't know. Is there anything special in the architecture of phar files? What should I do?
I googled a lot, but there was nobody having the same problem as mine.
The issue you describe sounds like you have detect_unicode enabled in your php.ini. You should disable it because it really is of no use and creates problems with phars.
By the way using the composer installer would do a check of settings and warn you about such problems.
php -d detect_unicode=Off composer.phar install
fixed it on MacOS X, it seems to reset my php.ini every now and then
Coming pretty late to this question, but I'd like to add that you can always run this command to verify php is configured correctly for Composer
curl -s https://getcomposer.org/installer | php -- --check
That will let you know if anything needs to be amended. If you get a blank output from Composer, that's the first place to go for help.