IMPORTANT: In the following commands, replace /home/your_username/bin
with the path to your current account's home directory (eg. /home/bob/bin
). Using the ~
shorthand will result in a failure.
Posted October 11th, 2019. Visit Composer's download page for a more recent version.
The only part of this script that is different from what Composer gives you on their download page is --install-dir=/home/your_username/bin --filename=composer
-- that's the part that will save you some hassle and make it easy to run Composer anywhere on your system.
Run the following to install Composer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=/home/your_username/bin --filename=composer
php -r "unlink('composer-setup.php');"
To run Composer, you should simply have to type composer
in your command line. Enjoy!
You'll want to run this from a directory with composer.json
in it to have these commands actually do anything.
If you're not sure what you're doing and you're in an existing repository, do not run composer update
. Just run composer install
.
Some commands to get started are composer
(lists commands), composer help
, composer install
.
More instructions: https://getcomposer.org/download/
Make sure you add the vendor/
folder Composer creates to you .gitignore
if you're using Git.
Should I commit the dependencies in my vendor directory? (no)