After some frustration trying to switch versions of PHP using Laravel Valet, I found out that valet has specific commands for running commands under an isolated version of PHP. Valet now allows you to set a project-level version of PHP so you no longer have to switch your installed version. The trick is using valet commands when running PHP.
- Make sure you are on the latest version of Laravel Valet: composer global require laravel/valet
- Isolate a project folder to a version of PHP: valet isolate [email protected]
- If you see the error: [email protected] has been disabled because it is a versioned formula, for PHP 7.3, you need to run these commands
- brew tap shivammathur/php
- brew install shivammathur/php/[email protected]
- Add alias helpers below
- Check the Laravel Docs for additional information.
Valet Alias Helpers
alias php="valet php" alias composer="valet php composer" alias pa="valet php artisan" alias phpunit='valet php ./vendor/bin/phpunit --testdox' alias pu='valet php artisan test --parallel'
New alias for running commands using @laravelphp Valet with isolated versions of PHP.
alias php="valet php"
alias composer="valet php composer"
alias pa="valet php artisan"
alias phpunit='valet php ./vendor/bin/phpunit –testdox'
alias pu='valet php artisan test –parallel' pic.twitter.com/QsLo8D9ZIS
— Tim Leland (@TimLeland) June 1, 2022
Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LY, Weather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.