Skip to content

Instantly share code, notes, and snippets.

@antoinefortin
Created March 16, 2018 13:49
Show Gist options
  • Save antoinefortin/c1630b9f0d3a96400da48816bb279085 to your computer and use it in GitHub Desktop.
Save antoinefortin/c1630b9f0d3a96400da48816bb279085 to your computer and use it in GitHub Desktop.
[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment