MacOS Install Composer globally

PanosDotK
1 min readNov 30, 2020

Download and Install Composer

First you must download the composer using the following curl command in your terminal:

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:

php composer.phar install

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

Add alias to composer

If you using bash. (Default shell on Mac OS <10.14, 2002–2019)

Open your ~/.bash_profile

nano  ~/.bash_profile

Add an alias to point at the composer.phar you moved into /usr/local/bin/*
Add the following line. It will create an alias of composer that can be used globally.

alias composer="php /usr/local/bin/composer"

If you using zsh. (Default shell on Mac OS 10.15+, 2019-Present)

Open your ~/.zshrc

nano  ~/.zshrc

Add an alias to point at the composer.phar you moved into /usr/local/bin/*
Add the following line. It will create an alias of composer that can be used globally.

Use composer globally

After restarting your terminal you will be able to access composer.

composer install

--

--