free-tech

How to install composer on MACOS


0 - Introduction:
Composer is a dependency management tool in PHP. It allows you to declare the libraries your project depends on and it will manage them for you.
composer doesn't  install/manage packages globally on the system  but it manages them per project by installing them on the vendor directory.

Here the 5 steps to install composer on MACOS:

1 - Run the following command to download Composer setup on MacOS :

$ sudo php -r "copy('https://getcomposer.org/installer','composer-setup.php');" 

2 - Check the installer hash :

php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

3 - run the composer setup

php composer-setup.php

4 - Move Composer.phar to /usr/bin/composer

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

5 - Run Composer

now composer installed in our system, just type composer on your terminal and you will get prompt help

 
#composer #php #macos