Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Install PHP Composer on MacOS?

  • Last Updated : 05 Jan, 2022

A composer is a tool for dependency manager in PHP. It is an important package manager for PHP. The package manager means it allows anyone to import codebases into the project and keep them updated and also helps in managing dependencies. Or we can say that it allows users to install the required libraries on a per-project basis and also allows them to use different versions of the required library in different PHP projects. Generally, the composer does not install anything globally so it is a dependency manager. But it does support a global project for convenience using the global command. You can easily use the libraries that are managed by the Composer by simply declaring them in your project in the standard format. 

Install PHP Composer on MacOS

Step 1: Browse to the official website using the URL to download the latest version of Composer.

Step 2: From the download page we have to copy the following commands:


php -r “copy(‘’, ‘composer-setup.php’);”

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

php composer-setup.php

php -r “unlink(‘composer-setup.php’);”

Step 3: Open your terminal and paste the above commands. Wait for some time.


Step 4: To check installation use the following command.

php composer.phar


Step 5: Move the compose to /usr/bin/composer to run composer globally on the terminal, so to do this use the following command:

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

Step 6: Run the composer. So to run the compose simply type composer on the terminal and press Enter.


Hence, your installation is successful.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!