Macos – Anyway to replace default /usr/bin/php with the homebrew one

macosPHP

The thing is that when using external tools in PHPStorm and launching command starting with php ... it automatically refers to /usr/bin/php and there's no way I can change it. I would have to run /usr/local/opt/php56/bin/php ... which I would rather not do.

So is there any way I can e.g. symlink that default php file so homebrew php is really default?

Best Answer

I don't know PHPStorm and the way how does it launch php, but two common ways to manage your binaries execution in unix-like systems are:

  1. set correct PATH variable order: export PATH=/usr/local/opt/php56/bin/:$PATH

  2. use aliases alias php='/usr/local/opt/php56/bin/php'

The first solution will expose not only php but also other binaries in your custom php to be used as first, the second one modifies only usage of php binary.

Put one of the entries in your profile.