It’s no secret that we love WP CLI at Chef du Web, but getting it to run on a local environment with MAMP is still pretty though, hence this blogpost.
If you’re on a local machine and you’re working with a tool like MAMP, you might have difficulty getting WP CLI to run. This is because WP CLI is looking for the native version of php shipped with OSX. In that case; first check the version of MAMP you’re running. Anything under 2.0 is pretty much impossible… i’d recommend setting up the build-in php and mysql servers in OSX directly, or setting up a nice Vagrant box. In any case; Make sure your version of OSX is running php 5.3.2 minimum! this is necessary for the install to work properly. Okay, so you’ve got an updated version of php, you’ve got MAMP 2.0; there are two things left to do; installing composer.phar (which is what WP CLI runs on) and pointing WP CLI to the right version of your PHP install;
First, install Composer:
cd wp-cli curl -sS https://getcomposer.org/installer | php php composer.phar install ./bin/wp --info
Then point WP CLI to the right php version in your .bash-profile file:
Once you’ve done that, refresh the .bash-profile file like this:
You can run to see if it worked.