⚠️ 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 [email protected] 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 [email protected] # Stop latest PHP brew services stop php brew unlink php # Activate PHP 7.1 brew link [email protected] --force brew services start [email protected]
🔥 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
# Tap exolnet/homebrew-deprecated $ brew tap exolnet/homebrew-deprecated # Installing these old versions will now work $ brew install [email protected] $ brew install [email protected]
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 [email protected]
After these steps here I (finally) got it working.
Thank me with a coffee.
I don't do this for profit but a small one-time donation would always put a smile on my face. Thanks!