For me, the valet use [email protected]
command does not work.
And so I created this bash function.
I already have PHP versions 7.2, 7.3 and 7.4 installed via Homebrew.
Add this function in your .bash_profile
or .zshrc
file:
# Switch PHP version
switch-php() {
valet stop
brew unlink [email protected] [email protected] [email protected]
brew link --force --overwrite php@$1
brew services restart php@$1
composer global update
rm -f ~/.config/valet/valet.sock
valet install
}
Then reboot your terminal.
Switch to PHP 7.4
switch-php 7.4
Switch to PHP 7.3
switch-php 7.3
Switch to PHP 7.2
switch-php 7.2
- macOS Catalina 10.15.6
- Homebrew 2.4.8
Thanks for the tip, it helped!
For Valet Linux: