Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override the path of PHP to use the MAMP path?

After screwing up entirely my PHP configuration on MAC trying to get the SOAP module working (-bash: /usr/bin/php: No such file or directory ....) I now have to use MAMP but each time I have to type the path

Applications/MAMP/bin/php5.3/bin/php to do command line. 

How to just type php instead the entire path on MAC ? I double checked and i do not have a file named .profile nor bash_profile

Thanks

PS: Here's what output echo $PATH :

echo $PATH /Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin 
like image 352
sf_tristanb Avatar asked Nov 10 '10 14:11

sf_tristanb


People also ask

Where is the PHP folder in MAMP?

If you are using MAMP Standard (the Free version) then you need to open either /Applications/MAMP/bin/php/php5.

Do you need MAMP for PHP?

MAMP stands for Mac Apache MySql PHP, this is needed if you want to run a PHP script on your local computer, not online.

How do I upgrade PHP to MAMP?

Setup a new or use old of your php website application on your MAMP htdocs directory ( /Applications/MAMP/htdocs/ ) and setup make sure you already enable vhost to application root directory. Go to your client Browser and test your PHP website. If there is no problem, you already succeed upgrade your MAMP PHP version.


1 Answers

In your home folder /Users/David for exmaple, you can create a .bash_profile. In here you can export variables and then add them to your path.

Open up the file to edit it in your favourite editor, I use vim.

Then you can add in your path

export MAMP_PHP=/Applications/MAMP/bin/php/php5.3.6/bin export PATH="$MAMP_PHP:$PATH" 

You want your bit ahead of the $PATH as that already includes /usr/bin which is where the system PHP lives. So the system will always find your MAMP version first.

Save this file and then reboot your Terminal and you'll see that you should get your MAMP version.

To test I use php -v as OSX Lion uses 5.3.10 and my MAMP is using 5.3.6
You can also test using which php which will output the path to your current php executable.

like image 172
David Yell Avatar answered Oct 01 '22 13:10

David Yell