Switching PHP versions with Laravel Valet

⚠️ Switching to a PHP version lower van 7.1 with Valet 2.0 won’t work at the time of writing, as Valet 2.0 does not work with PHP < 7.1 until this issue is resolved.

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

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:

# Stop latest PHP (version 7.2)
brew services stop php
brew unlink php

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

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@5.6

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

Switching PHP versions with Laravel Valet →

(via Freek)

Elsewhere , ,

Leave a Reply

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.