MAMP | Let’s make Terminal use MAMP’s PHP ( instead of mac’s version )

In MacOSX there is a default Apache + PHP server, but if you develop using MAMP, you need to use MAMP version’s of php instead the OSX one.
Here 3 steps for let’s say to terminal the existence of the MAMP’s PHP binaries and use them instead of the ones shipped with MacOSX.

1° step : Verify which PHP is used by your Terminal
Open terminal and add:

$ which php

With this commands you verify which PHP is your Terminal using.
As you can see ( if you are use default Mac OSX apache + php server ) you see as terminal response

” /usr/bin/php “

you can see, the MAMP’s folders don’t are showed. We have to add them to $PATH.

2° step : Add MAMP to $PATH variable

Now we have to modify the “$path” variable by modifying the file ” ~/.bash_profile ” located in root user folder.
We’ll made this by using VIM.
Open it in your terminal by typing:

sudo vi ~/.bash_profile

Since you call vi in sudo mode you’ll have to type your system password.
If you cannot edit the file, enter the Edit mode simply typing a.

Now write in the file the new “$path” variable that terminal has to use ( if you don’t know MAMP’s php version , open MAMP navigate to “Preferences -> PHP” and see the selected versions ).


Save the file, press “esc” to quit edit mode, then type


( or press “shift” and letter “z” for two times ).

3° step: Load “.bash_file” and check

It’s tiem to load new “.bash_profile” fiel:

$ source ~/.bash_profile

and check if all went good by typing one more time

$ which php

This time the response must be : ” /Applications/MAMP/bin/php/php7.1.12/bin/php ”
That’s right, from now terminal use MAMP’s PHP binaries.