Switching PHP versions with Laravel Valet

⚠️ Running Valet 2.x with a PHP version lower than 7.1 won’t work, until this issue is resolved. You can still switch to that version for use on the CLI. You just won’t be able to use it with Valet 2.x

ℹ️ UPDATE 2018.10.23: Freek has developed some handy aliases to easily switch PHP versions.

ℹ️ UPDATE 2019.08.12: With the release of Valet 2.2.0, it is now possible to change PHP versions using the valet command itself:

valet use php@7.2

valet use php

Valet will install the specified PHP version via Brew if it is not already installed.


For some older projects that I still need to run, I recently started using Valet. As those projects sometimes require different versions of PHP – or when I want to test them with the latest PHP version – I followed this set of instructions by Michael Dyrynda:

With the most recent Homebrew – in which PHP got moved to the core – I had to slightly tweak the commands a bit though:

# Install PHP 7.1 (you only need to do this once)
brew install php@7.1

# Stop latest PHP
brew services stop php
brew unlink php

# Activate PHP 7.1
brew link php@7.1 --force
brew services start php@7.1

🔥 Because they are no long supported, PHP versions 5.6 and 7.0 have been removed from homebrew/core. If you still need to install them, you can find them in the exolnet/homebrew-deprecated tap.

# Tap exolnet/homebrew-deprecated
$ brew tap exolnet/homebrew-deprecated

# Installing these old versions will now work
$ brew install php@5.6
$ brew install php@7.0

I noticed that after running these command you – somehow – might still have the “old” php service running as root (you can check with brew services list). In that case force it to stop, and restart the new version service:

sudo brew services stop php
brew services restart php@7.1

After these steps here I (finally) got it working.

Switching PHP versions with Laravel Valet →

(via Freek)

Did this help you out? Like what you see?
Thank me with a coffee.

I don\'t do this for profit but a small one-time donation would surely put a smile on my face. Thanks!

BuymeaCoffee (€3)

To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

Join the Conversation


  1. If you upgrade to the latest version of Valet, you can now switch using the command “valet use php@version”. If you don’t have that version, it will install via Homebrew and then switch.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.