At the time, PHP was installed through the homebrew-php tap. Here’s how I installed PHP 5.6 and 7.1 side by side, and how I switched between the versions. For the newer approach with the PHP formulae in the Homebrew core, see my post on a bash script for switching between PHP versions.
Install Homebrew-PHP
brew tap homebrew/dupesbrew tap homebrew/versionsbrew tap homebrew/homebrew-phpInstall PHP56
To list all available options:
brew options php56Install the PHP56 like so, assume that we don’t have any homebrew php version installed:
brew install php56brew services start homebrew/php/php56launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plistInstall PHP71
In case we have another homebrew-php version, uninstall it like so
brew unlink php56brew services stop homebrew/php/php56Then install the PHP71
brew install php71brew services start homebrew/php/php71launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plistSwitch PHP56 to PHP72
Unlink the PHP56 version first
brew unlink php56brew services php56Link the PHP72 version
brew link php72brew services start php72Update the PATH variable
vim ~/.zshrcexport PATH="$(brew --prefix homebrew/php/php72)/bin:$PATH"source ~/.zshrcSwitch PHP71 to PHP56
Unlink the PHP71 version first
brew unlink php71brew services stop homebrew/php/php71Link the PHP56 version
brew link php56brew services start homebrew/php/php56launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plistUpdate the PATH variable
vim ~/.zshrcexport PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"source ~/.zshrc