Please see comments for some important updates!
Valet, when told to use a specific version of PHP (using
valet use) symlinks
$HOME/.config/valet/valet.sock (on macOS) to a specific version of PHP installed on your system. If you use
valet use, unfortunately, it switches this symlink and your system PHP version.
But all you need to do is (with Homebrew) use
brew unlink php && brew link email@example.com --force --overwrite to tell your system to use PHP 8.1.x, that does not tell Valet what version to use,
valet use does.
If you use e.g.
valet use firstname.lastname@example.org you can simply use
brew unlink php && brew link email@example.com --force --overwrite to re-link your system back to using PHP 8. If you look at
$HOME/.config/valet/valet.sock you will notice it's still symlinked to
valet74.sock, and you can confirm with e.g.
It's a bit of a hack, but it works for me.
Take a look at some aliases I have setup to make this easy with
valet@7 which makes sure my system continues to run 8.1.
Top comments (1)
Okay, so this doesn't seem to be necessary anymore now that I ran into:
Apparently you can use
valet isolate firstname.lastname@example.org tell a specific site to use a specific version without modifying your system php version.
Now to go delete a bunch of unnecessary aliases!