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 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
I just set up WP CLI and it wasn't working because I had MAMP installed. I just set up WP CLI and it wasn't working because I had MAMP installed.
This advice fixed the issue at hand: This advice fixed the issue at hand:
  [<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>]
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. 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.
Open up the file to edit it in your favourite editor, I use vim. Open up the file to edit it in your favourite editor, I use vim.
Then you can add in your path Then you can add in your path
  export PATH=&quot;$MAMP_ PHP:$PATH&quot;[/js]
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. 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.
Save this file and then reboot your Terminal and you'll see that you should get your MAMP version. Save this file and then reboot your Terminal and you'll see that you should get your MAMP version.
To test I use <code>php -v</code> as OSX Lion uses 5.3.10 and my MAMP is using 5.3.6 To test I use <code>php -v</code> as OSX Lion uses 5.3.10 and my MAMP is using 5.3.6
You can also test using <code>which php</code> which will output the path to your current php executable. 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