How to install Composer globally on Mac OS
1. Download Composer
Install download the composer using the following curl command in your terminal, this is provided by the project itself:
curl -sS https://getcomposer.org/installer | php
After running that command, there will be a file
composer.phar in the current directory. You could use that command like this:
php composer.phar install
2. Installing Globally
In order to make composer available globally, allowing you to type
composer install anywhere, you have to move the recently downloaded composer.phar to local user’s bin folder:
mv composer.phar /usr/local/bin/composer
3. Open your shell profile
What shell are you using?
Using bash? (Default shell on Mac OS <10.14, 2002-2019)
~/.bash_profile (in text edit 😏)
open -e ~/.bash_profile
Using zsh? (Default shell on Mac OS 10.15+, 2019-Present)
~/.zshrc (in text edit 😏)
open -e ~/.zshrc
4. Add alias to composer
Add an alias to point at the
composer.phar you moved into
.bash_profile add the following line. It will create an alias of
composer that can be used globally.
alias composer="php /usr/local/bin/composer"
5. Use composer globally
After restarting your terminal you will be able to access composer like below:
There is a few way to accomplish this but I personally find the alias method the clearest and allows me to fully configure my shell. You could add
/usr/local/bin to your
PATH, see here.