DEV Community

Cover image for Install Composer on Mac / Linux /Unix machine
Dalitso Kasonde
Dalitso Kasonde

Posted on

Install Composer on Mac / Linux /Unix machine

To install composer using terminal your computer,
(Please note that installation requires that you have php already installed in your system)

  • Open the terminal
  • In your home directory type

{{ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');" }}

  • This command allows composer to only run in the home directory, to install composer globally type the following command

mv composer.phar /usr/local/bin/composer

  • After this step, the composer package can be used in any directory within your system.

  • Type composer in terminal to confirm

  • To learn more on how to use composer read official documentation on https://getcomposer.org/doc/

Top comments (1)

Collapse
 
hendisantika profile image
Hendi Santika

I was installing composer using brew.

But I am having this error:

image

Do You have any advice?

Thanks a lot