DEV Community

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

Posted on

1

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/

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

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

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay