Installing Composer on Mac OSX

Composer is a cross-platform dependency manager for PHP libraries.

In this guide, i'm installing Composer on a machine running Mac OSX with MAMP.

  1. Open a terminal and navigate to your user directory, ie cd /User/<USER_NAME>/
  2. Run this command shown below to download Composer. This will create a Phar (PHP Archive) file called composer.phar:
    curl -sS https://getcomposer.org/installer | php
    
  3. Now we move composer.phar file to a directory
    sudo mv composer.phar /usr/local/bin/
  4. We want to run Composer with having to be root al the time, so we need to change the permissions:
    sudo chmod 755 /usr/local/bin/composer.phar
    

     

  5. Next, we need to let Bash know where to execute Composer: 
    nano ~/.bash_profile
    

    Add this line below to bash_profile and save
     

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

    and then run this command:
     

    source ~/.bash_profile

     

  6. Finally, run: 
    composer -v
    

    If all goes well and it is working, you'll see this screen:
    Composer installed

 

Walter (not verified), 20 Mar 2020 - 2:09pm
Perfect! Thank you
Reynaldo (not verified), 21 Mar 2020 - 5:07pm
It worked perfectly! Thanks, man (or girl, idk).
James (not verified), 21 Mar 2020 - 6:30pm
That's brilliant. Clear, simple, easy to follow instructions. Thank you!
Damien (not verified), 23 Mar 2020 - 6:25pm
Wonderful !! Merci !
Arunjith R S (not verified), 24 Mar 2020 - 4:01pm
Perfect...Thanks alot
Robson Niedson (not verified), 24 Mar 2020 - 8:27pm
Obrigado. Funcionou bem!
Tércio (not verified), 30 Mar 2020 - 4:50am
Very good..
Daniel (not verified), 01 Apr 2020 - 8:18am
mv: rename composer.phar to /usr/local/bin/: No such file or directory
ERROR
Lemaro (not verified), 02 Apr 2020 - 12:33pm
You are the best! Thx God! Add it please to official docs, cause there not smart instructions for bots :\
Arif Budiman (not verified), 17 Apr 2020 - 1:31am
thank you bro
Phoenix2222 (not verified), 18 Apr 2020 - 8:33pm
Thanks Bro =)
Bryan from Smmile (not verified), 20 Apr 2020 - 4:56pm
Thanks, best tutorial!
Ace5193 (not verified), 25 Apr 2020 - 5:35pm
Thank you
Marco Castellani (not verified), 08 May 2020 - 9:56am
Thanks a lot!
Michael (not verified), 16 Jun 2020 - 8:44am
You can skip step 5 if you do this in step 3:

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

and then also lose the ".phar" in step 4
The content of this field is kept private and will not be shown publicly.
Your email address will be kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.