Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Configure the PHP CLI in macOS to use MAMP PHP binaries


Find MAMP's installed PHP version(s) you want to use the PHP CLI for:

$ ls -l /Applications/MAMP/bin/php/

Configure PHP CLI in macOS to use MAMP's PHP

  1. First, open your local user's .bash_profile in edit mode, in order to add aliases for accessing the PHP CLI locally
$ pico ~/.bash_profile
  1. Then add any alias to any of MAMP's PHP binaries and your preferred command to access each of them:
alias php5=/Applications/MAMP/bin/php/php5.6.37/bin/php
alias php7=/Applications/MAMP/bin/php/php7.2.8/bin/php
  1. Save and exit the editor & reload your .bash_profile
$ source ~/.bash_profile

Alternative: changing the default php shell command to a MAMP PHP binary

If you just want to have the php command by default using a MAMP PHP binary – instead of the macOS one, update your .bash_profile as follows:


Check if everything works as expected

Use e.g. the Version info to check if your alias or PATH changes work as expected:

$ php5 -v
    PHP 5.6.37 (cli) (built: Aug 28 2018 16:24:00) 
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
        with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
$ php7 -v
    PHP 7.2.8 (cli) (built: Aug 28 2018 16:32:29) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies



This comment has been minimized.

Copy link

@vossiermaxime vossiermaxime commented Dec 17, 2020

thanks !

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