Giuseppe Iaria
Giuseppe Iaria

Reputation: 311

How to install Composer on macOS?

I was trying to install the Composer on my macOS version: high sierra--> 10.13.4

but after using the command:

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 

It created some files and directory but it didn't download the composer. My terminal displayed following error:

No log handling enabled - using stderr logging

Created directory: /var/db/net-snmp

Created directory: /var/db/net-snmp/mib_indexes`

How can I resolve this problem?

Upvotes: 31

Views: 59338

Answers (3)

Oladimeji Ajeniya
Oladimeji Ajeniya

Reputation: 386

Download and Install composer using the following curl command in the terminal:

curl -sS https://getcomposer.org/installer | php

After the installation, you will have composer.phar file in the current directory and the composer command is available as:

 php composer.phar [composer commnad]

To make composer available globally, you have to move the recently downloaded composer.phar to the local user’s bin folder as follows:

go to /usr/local/bin folder. 

You can click Shift + Command + G to open the dialog to go to the folder. Move the recently downloaded composer.phar to the usr/local/bin folder create an alias using the command

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

Now, you can access the composer from the terminal simply using the composer command. That's it.

Upvotes: -7

Lukas
Lukas

Reputation: 1123

OLD Answer (The Ruby Homebrew installer is now deprecated and has been rewritten in Bash.):

First install Brew on your MAC:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

NEW Answer:

First install Brew on your MAC:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install PHP:

brew update
brew install php
brew install composer

To test installation, run:

 $ composer -V

Upvotes: 72

Sarthak Raval
Sarthak Raval

Reputation: 1291

  1. Install Brew in Mac Terminal

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  1. Install Composer

brew install composer

  1. Check Composer

composer -V

Upvotes: 3

Related Questions