Change PHP path to MAMPs PHP

I am running PHP with MAMP on OSX 10.5.8

So, if I want to run a script from the console, I always need to write

/applications/mamp/bin/php5.3/bin/php path/to/script 

which is annoying. Is there a way to change the default path to php so that I can write

 php path/to/script 

and still using the PHP version of MAMPs?

+4
source share
6 answers

Create a file called .bash_profile in your home directory (if you do not already have this file) and add it to the file:

 export PATH=/Applications/mamp/bin/php5.3/bin:$PATH 

Then close and restart Terminal.app

+16
source

Use the latest version of MAMP PHP

you need to edit the .bash_profile file

 open -a TextEdit ~/.bash_profile 

if you cannot find bash_profile in your home directory then create .bash_profile:

  touch ~/.bash_profile 

Use the latest version of MAMP PHP

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

(Use the original ~ / .bash_profile file after making the changes to make sure they take effect.)

source: How to override the PHP path to use the MAMP path?

+6
source

The easiest way is to rewrite the alias. Just copy / paste cmd into the terminal for temporary use or write it to .bash_profile to make it permanent.

For MAMP

 $ alias php=/applications/mamp/bin/php5.3/bin/php 

For XAMPP

 $ alias php=/Applications/XAMPP/bin/php 

For AMPPS

 $ alias php=/Applications/AMPPS/php-5.6/bin/php 

Run php through our new alias

 $ php -v 
+4
source

In addition to bfvarettos, the excellent answer is: since .bash_profile is executed when you log in, you will need to reboot the system for the changes to take effect.

+1
source

I'm not sure if this applies to MAMP 3.0 or not, but you need to do the following path for MAMP 3.0. Make sure you change the version of PHP to the version used for your server.

Again this happens in ~ / .bash_profile

 export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH 
0
source
 vi ~/.bash_profile //add export PATH=/path/to/php/bin:$PATH source ~/.bash_profile 
0
source

Source: https://habr.com/ru/post/1415651/


All Articles