WP Migrate CLI and MAMP

WP Migrate is a great tool well worth the slightly steep investment. The time and effort saved from a one click deployment huge. WP Migrate CLI takes this to another level with the ability to push an entire deployment from the command line.

If you’re running MAMP locally wp-cli may be using a different version of PHP than MAMP resulting in DB errors such as

wp-cli error establishing a database connection

This can be fixed by setting your bash/sh/git/[insert your shell] PHP version to use the same as is used by MAMP.

Add this to your ~/*.rc config file followed by source ~/*.rc to update your PHP binary path

PHP_VERSION=$(ls /Applications/MAMP/bin/php/ | sort -n | tail -1)
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH

Bish bash bosh, simple, repeatable, less error prone deployments are yours!

Help other people find this

Leave a Reply

Your email address will not be published. Required fields are marked *