Composer is a dependency management tool for php projects. By using composer, you can just declare the dependecy in your project and composer will handle/download this for you.
Unlike yum or apt -in linux distros, composer manages the pacakge per project basis. However, it does not install anything globally, but everything required for a particular project.
Composer may got some inspiration from the node’s npm package manager. Composer needs at least PHP 5.3.2 in your system/server.
So today’s tutorial we are showing how to install Composer in Mac OS.
- Open a your terminal and navigate to your Users directory.
You can use below command to go to users directory from anywhere.
then move to
cd /Users/[your username]>
- Run the below command to download Composer to your system. This will create a Phar (PHP Archive) file in the selected directory.
curl -sS https://getcomposer.org/installer | php
- Now we need to move composer.phar file to a directory, to access globally.
sudo mv composer.phar /usr/local/bin/
- Next, change the permission of Composer to run as root user. Run the below command.
sudo chmod 755 /usr/local/bin/composer.phar
- Next, we need to update Bash file to set which location to find our Composer.
- Add this line below to bash_profile and save
alias composer="php /usr/local/bin/composer.phar"
- and then we will run the below to read and execute.
- At last step, run
If everything went smooth and staring you will see a output similar to below.