Thursday, July 23, 2020

How to install composer in MAC OS

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 calledcomposer.phar:
    curl -sS https://getcomposer.org/installer | php
    
  3. Now we move composer.phar fileto 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