I'd really like to know about this as well. It feels like it should be possible if you have PHP7 and PHP5.6 installed and add an entry into ~.valet/Caddyfile that uses the PHP5.6 version fastcgi or something.
Anyone else have any ideas?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I just got started on Valet and I wanted to setup a custom driver where it uses PHP5.6 instead of PHP7.0. I looked through the docs, but couldn't find anything about shifting PHP version, is this possible to do as a custom driver? And is it even possible at all to shift the PHP version of Valet?
Ok I think I've got this working so here's how I did it. Most of the credit goes to to Jani Tarvainen for this post: http://share.ez.no/blogs/ez/how-to-run-both-php-5.6-and-php-7.0-with-homebrew-on-os-x-with-php-fpm
My examples are for PHP 5.3 so I'm fairly sure it would work for 5.4, 5.5 and 5.6. Just change 53 to 56 or whatever version you are using.
I'm assuming you have Valet and PHP 7.0 installed and working ok.
Install another version of PHP
PHP 5.3 will be installed but PHP 7.0 remains the default.
brew unlink php70
brew install php53
brew unlink php53
brew link php70
Configure an additional PHP-FPM on a different port to listen for PHP5.3 requests
Edit File
/usr/local/etc/php/5.3/php-fpm.conf
Change
listen = 127.0.0.1:9000
to
listen = 127.0.0.1:9053
Start both PHP-FPMs on startup
cp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/
cp /usr/local/opt/php53/homebrew.mxcl.php53.plist ~/Library/LaunchAgents/
Start both PHP-FPMs now
Only required this time, they will start automatically on next boot up.
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist
Configure Caddy
Caddy is the underlying web server that Valet uses. We can make it use site specific config that only applies to the PHP5.3 site. Other sites will continue to be served by PHP7. You will need to tweak this file to suit your needs so check the Caddy docs. https://caddyserver.com/docs
Create a file called
~/.valet/Caddy/MyOldProject.conf
Add the below
oldproject.dev:80 {
root /Users/rob/Code/oldproject
fastcgi / 127.0.0.1:9053 php
rewrite {
to {path} {path}/ /index.php?{query}
}
log /Users/rob/.valet/Log/access.log {
rotate {
size 10
age 3
keep 1
}
}
errors {
log /Users/rob/.valet/Log/error.log {
size 10
age 3
keep 1
}
}
}
Restart Valet and test
valet restart
Note If you edit the PHP5.3 ini file (/usr/local/etc/php/5.3/php.ini) then I think you will need to restart PHP with:
brew services restart php53
Please or to participate in this conversation.