You are viewing an old revision of this post, from December 8, 2015 @ 22:30:35. See below for differences between this version and the current revision.

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: [http://stackoverflow.com/questions/4145667/how-to-override-the-path-of-php-to-use-the-mamp-path/10653443#10653443] 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 [js]export MAMP_PHP=/Applications/MAMP/bin/php/php5.3.6/bin export PATH="$MAMP_PHP:$PATH"[/js] 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.

Revisions

  • December 8, 2015 @ 22:31:17 [Current Revision] by PeterLugg
  • December 8, 2015 @ 22:31:17 by PeterLugg
  • December 8, 2015 @ 22:30:35 by PeterLugg

Revision Differences

December 8, 2015 @ 22:30:35Current Revision
Content
Unchanged: I just set up WP CLI and it wasn't working because I had MAMP installed.Unchanged: I just set up WP CLI and it wasn't working because I had MAMP installed.
Unchanged: This advice fixed the issue at hand:Unchanged: This advice fixed the issue at hand:
 Added: [<a href="http:// stackoverflow.com/questions/ 4145667/how-to- override-the- path-of-php-to- use-the-mamp- path/10653443#10653443">http: //stackoverflow.com/questions/ 4145667/how-to- override-the- path-of-php-to- use-the-mamp- path/10653443#10653443</a>]
Unchanged: In your home folder <code>/Users/ David</code> for exmaple, you can create a <code>.bash_profile</code>. In here you can export variables and then add them to your path.Unchanged: In your home folder <code>/Users/ David</code> for exmaple, you can create a <code>.bash_profile</code>. In here you can export variables and then add them to your path.
Unchanged: Open up the file to edit it in your favourite editor, I use vim.Unchanged: Open up the file to edit it in your favourite editor, I use vim.
Unchanged: Then you can add in your pathUnchanged: Then you can add in your path
Unchanged: [js]export MAMP_PHP=/Applications/ MAMP/bin/php/ php5.3.6/binUnchanged: [js]export MAMP_PHP=/Applications/ MAMP/bin/php/ php5.3.6/bin
Unchanged: export PATH=&quot;$MAMP_ PHP:$PATH&quot;[/js]Unchanged: export PATH=&quot;$MAMP_ PHP:$PATH&quot;[/js]
Unchanged: You want your bit ahead of the <code>$PATH</code> as that already includes <code>/usr/bin</code> which is where the system PHP lives. So the system will always find your MAMP version first.Unchanged: You want your bit ahead of the <code>$PATH</code> as that already includes <code>/usr/bin</code> which is where the system PHP lives. So the system will always find your MAMP version first.
Unchanged: Save this file and then reboot your Terminal and you'll see that you should get your MAMP version.Unchanged: Save this file and then reboot your Terminal and you'll see that you should get your MAMP version.
Unchanged: To test I use <code>php -v</code> as OSX Lion uses 5.3.10 and my MAMP is using 5.3.6Unchanged: To test I use <code>php -v</code> as OSX Lion uses 5.3.10 and my MAMP is using 5.3.6
Unchanged: You can also test using <code>which php</code> which will output the path to your current php executable.Unchanged: You can also test using <code>which php</code> which will output the path to your current php executable.

Note: Spaces may be added to comparison text to allow better line wrapping.

Tags: , ,

No comments yet.

Leave a Reply