brew install php
installs php 7.3 at the moment, versions below are keg-only
You can make aliases for versions below by adding this to:
~/.profile
alias php@5.6='$(brew --prefix php@5.6)/bin/php'
alias php@7.0='$(brew --prefix php@7.0)/bin/php'
alias php@7.1='$(brew --prefix php@7.1)/bin/php'
alias php@7.2='$(brew --prefix php@7.2)/bin/php'
~/.bashrc
source ~/.profile
~/.zshrc
[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
Then you can:
php@5.6 -v
php@7.0 -v
php@7.1 -v
php@7.2 -v
If you use composer and the platform php is not set in your project then this can be handy:
~/.profile
alias composer@5.6='php@5.6 $(which composer)'
alias composer@7.0='php@7.0 $(which composer)'
alias composer@7.1='php@7.1 $(which composer)'
alias composer@7.2='php@7.2 $(which composer)'
If you use artisan a lot (artisan maps to php which is 7.3) then this can be handy:
~/.profile
alias artisan@5.6='php@5.6 artisan'
alias artisan@7.0='php@7.0 artisan'
alias artisan@7.1='php@7.1 artisan'
alias artisan@7.2='php@7.2 artisan'