How to install composer for PHP
This article describes how to install and configure composer, a PHP dependency manager. Composer enables you to manage dependencies for each project independently, and is used by frameworks such as Laravel.
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. Replace username with your account username:echo ‘alias composer=”php -d allow_url_fopen=On /home/username/composer.phar”‘ >> ~/.bashrc source ~/.bashrcYou 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/username/composer.phar”‘ >> ~/.bashrc source ~/.bashrcFor more information about how to use alternate PHP versions on A2 Hosting servers that do not use CageFS, please see this article.
- 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
- To confirm composer installed correctly, type the following command:composer -VComposer 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:
note : Jika menggunakan suhosin, tambahkan script ini di php.ini
“suhosin.executor.include.whitelist=phar”Julian's | 4 views