Recently we have been required to develop for PHP 7.4 while maintaining older PHP 7.2 sites. Using Laravel Valet has become the norm for us, but switching PHP versions is not always obivous. Below is a list of command to change version from PHP 7.4 to PHP 7.2 and back again. You can also use this to switch to older PHP 5.6, 7.0, 7.1 etc. as long as you have them installed.
Switch PHP 7.4 to 7.2
valet stop
brew services stop php@7.4
brew unlink php@7.4
# Might have to update bash profile
nano ~/.bash_profile
source ~/.bash_profile
# OR
brew link php@7.2 --force
composer global update
brew services start php@7.2
valet start
Switch PHP 7.2 to 7.4
valet stop
brew services stop php@7.2
brew unlink php@7.2
# Might have to update bash profile
nano ~/.bash_profile
source ~/.bash_profile
# OR
brew link php@7.4 --force
composer global update
brew services start php@7.4
valet start
Comments are closed.