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 [email protected]
brew unlink [email protected]
# Might have to update bash profile
nano ~/.bash_profile
source ~/.bash_profile
# OR
brew link [email protected] --force
composer global update
brew services start [email protected]
valet start
Switch PHP 7.2 to 7.4
valet stop
brew services stop [email protected]
brew unlink [email protected]
# Might have to update bash profile
nano ~/.bash_profile
source ~/.bash_profile
# OR
brew link [email protected] --force
composer global update
brew services start [email protected]
valet start
Comments are closed.