Installing composer
Learn how to install and configure composer, a PHP dependency manager with this guide.
This article describes how to install and configure PHP composer , the dependency manager solution. Composer enables you to manage dependencies for each project independently, and is used by frameworks such as Laravel.
Installing composer
To install composer, follow these steps:
-
Log in to your account using SSH.
-
To configure your shell environment to use composer, type the following commands:
echo 'alias composer="php -d allow_url_fopen=On ${HOME}/composer.phar"' > ~/.bashrc source ~/.bashrc
Tip
You can use composer with alternate PHP versions as well:
-
On an account that has CageFS enabled, all you need to do is select the PHP version in cPanel that you want to use. For information about how to do this, please see this article.
-
On an account that does not have CageFS enabled, you must manually specify the path to the PHP executable in the ~/.bashrc file. For example, if you want to run composer using PHP 5.5, type the following commands instead:
echo 'alias php="/opt/php/php-5.5.0/bin/php"' > ~/.bashrc echo 'alias composer="/opt/php/php-5.5.0/bin/php -d allow_url_fopen=On ${HOME}/composer.phar"' > ~/.bashrc source ~/.bashrc
-
-
To download the composer installer, type the following commands:
cd ~ curl -k -O https://getcomposer.org/installer
-
To install composer, type the following command:
php -d allow_url_fopen=On installer
Note
- To confirm composer installed correctly, type the following command:
composer -V
Composer should display the version number. If it does not, repeat steps 2 to 4, paying close attention to the paths.
- To update the composer installation to the newest version in the future, type the following command:
composer self-update
More Information
For more information about PHP Composer, please visit https://getcomposer.org.
Updated 3 days ago