The problem
Laravel Valet currently support PHP 8 and higher versions (8.1, 8.2), but if you try to switch from PHP 8.1 to PHP 7.4 for a legacy project (as an example) it would be a headache.
The problem would be, when you need to return to an updated PHP version... there would start the real mess...
Solution
Lets supposed that we are currently in PHP 8.1 version, then to work on a legacy project you would require to switch to PHP 7.4 as an example:
valet use php@7.4
It would work, then to return to an updated PHP version (8.1 or 8.2), you would face an issue if you try to switch back with this command:
// use to work with the most recent version
valet use php
Fix the issue and go back to the most recent PHP version:
This command would unlink all 7.x versions, (but you can unlink only a specific one):
brew unlink php@7.0 php@7.1 php@7.2 php@7.3 php@7.4
Install the most recent PHP version, (if the system does not have it):
brew install php
Then it would link the most recent PHP version
brew link php
If this last command does not work, you can use some flags to force it:
brew link --force --overwrite php
Then just instruct Valet to use the most recent PHP version:
valet use php --force
Hope it helps and thanks for reading, happy coding!
Top comments (0)