antoinefortin
3/16/2018 - 1:49 PM

[Change Php in Bash]

[Change Php in Bash]

Another way without changing the original php file / link is if you edit your .bashrc file as follows (works with other commands as well):

Open your Terminal / Commandline and type in:

vim ~/.bashrc
Then press "i" to get into edit-mode (if there shows up a problem before that, because of a swap file, then press "E" to edit the file anyway)
Add the following line (change the path as needed):

alias php="/Applications/MAMP/bin/php/php5.4.10/bin/php"
Press "ESC" and type in ":wq"
If you need the php-alias to work right out of your current shell-session, then you have to use the following command (that's optional, so only if u r continuing to work in your current shell):

source ~/.bashrc
That's it, no change in the /usr/bin folder needed, and u can export your bashrc file / settings to any other linux / bsd like system if needed without even touching your OS /usr/bin files. You can also add new aliases for different php versions, aliases like "php52", "php53", "php54", etc. for testing purposes or whatsoever.

Have fun, ioCron