EDIT:
As of 2018 and the latest updates to Brew your php formula names have the following format [email protected]
.
When you run brew info [email protected]
your path should be /usr/local/Cellar/[email protected]/
And there will be a symbolic link to /usr/local/bin/opt/[email protected]/
So in order to change your php installation you just need to run this in terminal:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
or put it manually in your .bash_profile
like this:
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
===========================================================================
The location of your Homebrew installed php should be /usr/local/Cellar/php72
These are the steps you need to do to setup your PHP on macOS:
After you install php with brew run this in terminal:
export PATH="$(brew --prefix homebrew/php/php72)/bin:$PATH"
Then run:
source ~/.bash_profile
To check your current active version of php run this in terminal:
which php
EDIT:
run brew info php72
in console to get all info, hints and caveats for php, it is really useful, for example this comes from brew info:
✩✩✩✩ PHP CLI ✩✩✩✩
If you wish to swap the PHP you use on the command line, you should add the
following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent
configuration file:
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"