How to install Composer on macOS?

27,250

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
Share:
27,250
Admin
Author by

Admin

Updated on February 02, 2022

Comments

  • Admin
    Admin over 2 years

    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?

  • Abed Putra
    Abed Putra over 5 years
    show error: 1. Error: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated. 2. Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.
  • Yorick
    Yorick about 5 years
    homebrew/dupes is now part of core - stackoverflow.com/questions/45124717/… same with homebrew/php github.com/weprovide/valet-plus/issues/127
  • Mir Stephen
    Mir Stephen about 3 years
    I tried composer update --ignore-platform-reqs on top of those command and it worked
  • Tim Rogers
    Tim Rogers about 2 years
    Step 3 should be composer -V with a capital V.