Dev.to WebDev 🛠 Dev 👁 0 📖 2 min read

How to Run PHP 8.6 Side-by-Side With PHP 8.3–8.5 on macOS Without Breaking Laravel

PHP 8.6 is officially out — and right on cue, running a careless brew upgrade php is the fastest way to break three active Laravel or WordPress projects on your Mac. Between strict deprecation changes, Composer platform

PHP 8.6 is officially out — and right on cue, running a careless brew upgrade php is the fastest way to break three active Laravel or WordPress projects on your Mac.

Between strict deprecation changes, Composer platform checks, and Homebrew's dynamic library bumps (icu4c, openssl), upgrading a single global PHP binary on macOS almost always causes avoidable downtime.

Here is the clean way to run PHP 8.6 side-by-side with PHP 8.3–8.5 on Apple Silicon (M1–M4) and Intel Macs using isolated PHP-FPM Unix sockets.

1. Test PHP 8.6 Safely via Homebrew Without Changing Global PATH

Homebrew ships the newest stable release under the unversioned php formula (8.6.0), while older series live under [email protected], [email protected], etc. You can install PHP 8.6 without disturbing your daily driver:

# Install PHP 8.6 alongside your existing PHP 8.4/8.3
brew install php

# Verify PHP 8.6 directly via its opt path (Apple Silicon)
/opt/homebrew/opt/php/bin/php -v

# Check Composer platform compatibility without mutating composer.lock
/opt/homebrew/opt/php/bin/php $(which composer) check-platform-reqs

# Run your test suite specifically on PHP 8.6
/opt/homebrew/opt/php/bin/php artisan test

(On Intel Macs, replace /opt/homebrew with /usr/local.)

2. Isolate Web Requests With Per-Version PHP-FPM Unix Sockets

Instead of routing every local Nginx virtual host through a single php-fpm.sock (or port 9000 where versions collide), give each PHP minor version its own Unix socket:

# Legacy client app stays pinned to PHP 8.3
location ~ \.php$ {
    fastcgi_pass unix:/tmp/php83-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

# Upgrade test branch runs PHP 8.6 in parallel
location ~ \.php$ {
    fastcgi_pass unix:/tmp/php86-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

Because each pool binds to its own socket file, PHP 8.3, 8.4, 8.5, and 8.6 can serve requests simultaneously with zero port conflicts and zero restarts when switching projects.

3. Pair Side-by-Side PHP With Git Worktrees

git worktree add ../myapp-php86 -b chore/php-8.6-upgrade

Now you can open https://myapp.test (PHP 8.4) and https://php86.myapp.test (PHP 8.6) side-by-side in two browser tabs, compare responses, and run php artisan test without ever stashing work or touching your main branch.

4. Automating Isolated Pools on macOS

If you'd rather not hand-maintain Nginx fastcgi_pass configs, Keychain Root CAs, or FPM pool files, Stratos automates per-site PHP-FPM Unix sockets, Keychain-trusted .test HTTPS, automatic Git worktree branch subdomains, MailCatcher (port 1025), and DumpServer (port 9912) in a native Swift macOS app.

Have you tested your Laravel or WordPress stack on PHP 8.6 yet? Drop any extension or package gotchas you've hit in the comments!

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.