OSX has PHP shipped with it but when faced with tasks that require specific versions of which, you'll soon realize that messing around updgrading/downgrading your machine requires a great deal of time--MAMP to the rescue.
All is well until you use PHP in the command line and realize running the script in terminal uses a different version than that of which MAMP uses. Right, it runs the executable from the path where the PHP that came with your mac is installed.
Fire up the terminal or iTerm and copy the code below making sure you modify according to your MAMP installation path and the version (PHP_VERSION) you want to run.
export MAMP_PHP=/Applications/MAMP/bin/php/PHP_VERSION/bin export PATH="$MAMP_PHP:$PATH"
You can then check your where PHP is running by running
which -a php on the command line which should output something like below.
$ which -a php /Applications/MAMP/bin/php/php5.3.20/bin/php /usr/bin/php
Notice that it added the
MAMP_PHP value to your paths.
It Stopped Working?
The export will only last during that session, paths will revert back as soon as you close the window. To make your paths permanent, you need to copy the code provided above in your shell's config file which are usually in your user folder with names such as .bashrc, .bashprofile, _.profile, .zshrc depending on which shell you are using.
Make Sure you include the command
export when copying above!
Hope it helps!