Skip to content

Instantly share code, notes, and snippets.

@ayuthmang
Last active July 23, 2018 02:10
Show Gist options
  • Save ayuthmang/abf4d57168f72ed5bd6e311b1130328d to your computer and use it in GitHub Desktop.
Save ayuthmang/abf4d57168f72ed5bd6e311b1130328d to your computer and use it in GitHub Desktop.
Install composer on macOS

Install composer on macOS

Official installation guide

Install the composer

I've adapted some command line below for make our life easier, so just copy and paste line by line and execute it interminal. If you want to view official installation guide let's see official installation guide.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"

After everything install coorectly we'll make alias. In this case, I've using the zsh as my default terminal here is a command for adding an alias.

In case if you're using the default bash just change ~/.zshr to vi ~/.bash_profile.

vi ~/.zshrc

Put the line below on somewhere in file (that'll make us be able to call composer on commandline)

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

Reload current shell's environment with following command(or just close and re open the terminal).

source ~/.zshrc

That's all

If you're interested with zsh or new generation of terminal please see this link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment