wp-cli

You heard of WP-CLI and decided that it can really help you to speed up your development process, but once you install it on your mac and start performing cli tricks you keep bumping into Error establishing a database connection

The reason this happens is wp-cli is not making good friends with MAMP out of the box. Fortunately this is easy to fix. To do so cd into your home directory and add the following to your .bashrc file. If the file does not exists feel free to create one.

This goes in .bashrc file

# FIX PHP MAMP for WP-CLI
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
export PATH=$PATH:/Applications/MAMP/Library/bin/

Please take note that you might want to change the php version depending on which you are currently using. Because the path indicates on the version you are running locally. You can check it in the terminal using php -v or in mamp preferences, PHP tab

mamp preferences

Finally you can start using the command line tool to its fullest potential.

AntonK52

My name is Anton and I am a front end developer. This website is nothing but a place where I can pile up the solutions to web related problems I have not found a solution as well my thoughts that are longer than 140 characters.