Get WP CLI to use MAMP’s version of PHP

I just set up WP CLI and it wasn’t working because I had MAMP installed.

This advice fixed the issue at hand:

In your home folder /Users/David for exmaple, you can create a .bash_profile. In here you can export variables and then add them to your path.

Open up the file to edit it in your favourite editor, I use vim.

Then you can add in your path

export MAMP_PHP=/Applications/MAMP/bin/php/php5.3.6/bin
 export PATH="$MAMP_PHP:$PATH"

You want your bit ahead of the $PATH as that already includes /usr/bin which is where the system PHP lives. So the system will always find your MAMP version first.

Save this file and then reboot your Terminal and you’ll see that you should get your MAMP version.

To test I use php -v as OSX Lion uses 5.3.10 and my MAMP is using 5.3.6
You can also test using which php which will output the path to your current php executable.


Tags: , ,

No comments yet.

Leave a Reply