How to Switch PHP Versions with Laravel Valet

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.


  1. Make sure you are on the latest version of Laravel Valet: composer global require laravel/valet
  2. Isolate a project folder to a version of PHP: valet isolate [email protected]
  3. 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
    1. brew tap shivammathur/php
    2. brew install shivammathur/php/[email protected]
  4. Add alias helpers below
  5. 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'

Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LYWeather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.  

Leave a Reply

Your email address will not be published. Required fields are marked *