Open-source project
shivammathur/homebrew-php avatar
shivammathur/homebrew-php

shivammathur/homebrew-php: multiple PHP versions on macOS arm64 and Linux without compiling

Homebrew tap for PHP 5.6 to 8.6. PHP 8.6 is built nightly :beer:

2,873 stars184 forksRubyMIT

At a glance

What is it?
A Homebrew tap that ships prebuilt PHP formulae from 5.6 to 8.7.0-dev, including ZTS and debug variants. It is the practical way to keep several PHP versions side by side on an Apple silicon Mac, and it deliberately drops macOS Intel.
Who is it for?
Adopt this tap if you develop on Apple silicon or Linux and need to switch between PHP branches, or need ZTS and debug builds for extension work. Do not adopt it if you are on macOS Intel, which the OS support table lists as unsupported, or if you want several PHP versions active simultaneously, since the workflow is link and relink.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 8 days ago.
What is it written in?
Mainly Ruby, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 24, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The gap this tap fills for PHP version switching

Homebrew core carries one current PHP formula. That is fine until you need to run a legacy application on 7.4 while a new project targets 8.5, or until you need a thread-safe build to compile an extension. This tap exists to cover those cases: the PHP Support table lists formulae from [email protected] through [email protected], and each version has four variants. The plain formula is non-thread-safe, the -zts suffix adds thread safety, -debug adds debug symbols, and -debug-zts combines both. The README states that debug formulae are meant for building or debugging PHP extensions and are not recommended for production, and that ZTS formulae are for applications that require multi-threading support. The audience is therefore narrower than "anyone who uses PHP": it is developers who need version breadth or a specific build flavour that the default formula does not provide.

How the tap is structured and what it does at install time

The repository is a Homebrew tap, not a build system of its own. The Formula directory holds the Ruby formula files, Aliases holds shortcut names, and Scripts holds the tooling that keeps the formulae current. The README describes PHP 8.6 as built nightly, which matches the version label 8.6.0-dev in the support table: this is a development branch that moves. When you run brew install against a formula in this tap, Homebrew resolves the formula from the tap rather than from core, downloads the matching prebuilt bottle for your platform, and places it in the Cellar. Nothing is compiled from PHP source on your machine unless no bottle matches. The formula names are namespaced, so the install command is written as shivammathur/php/[email protected] rather than [email protected]. That namespacing is what lets this tap coexist with Homebrew core without the two fighting over the same formula name. The trade-off is verbosity: every command in the README carries the full tap path.

Installing the tap and running PHP 8.5 for the first time

Prerequisites differ by platform. On macOS the README asks for Xcode Command Line Utilities, installed with xcode-select --install. On Linux it asks for cURL and Git, installed through APT or Yum. Homebrew itself comes from the official install script. Once Homebrew is present, fetching the tap and marking it trusted are two separate steps, and the README gives both:

zsh
brew tap shivammathur/php
brew trust shivammathur/php

With the tap in place, install a version. The README's example uses 8.5:

zsh
brew install shivammathur/php/[email protected]

Installing does not put php on your PATH. The README is explicit that you have to link it afterwards, and that the link uses --overwrite --force:

zsh
brew link --overwrite --force shivammathur/php/[email protected]

After restarting the terminal, php -v should report the version you linked. If you use Apache or Nginx with php-fpm, the README notes that a webserver restart is required after any PHP change, through brew services restart httpd or brew services restart nginx respectively.

Upgrades, relinking, and the warning you will hit

Upgrading within a branch is a single command, for example brew upgrade shivammathur/php/[email protected], which the README describes as moving you to the latest patch release. Switching between installed versions reuses the link command rather than an install command, so the mental model is one linked PHP at a time. The failure mode here is a linking warning the README quotes directly: "Warning: Already linked: <Cellar Path>". The recommended recovery is to unlink and relink:

zsh
brew unlink [email protected]
brew link --overwrite --force shivammathur/php/[email protected]

The --overwrite --force flags are not decorative. They are what allows this link to displace whatever else claims the php binary. That also means the command can overwrite files you did not expect it to touch, which is worth knowing before running it on a machine where another PHP installation is managed by a different tool. The README's debugging section is short: run brew update before installing, and run brew doctor and fix what it reports. It does not document rollback to a previous patch release, so if you need to pin an exact patch, the README is silent on how.

Platform limits and the macOS Intel omission

The OS Support table is the most consequential part of the README. Linux is supported on x86_64 and arm64. macOS is supported on arm64 only, across Sequoia, Tahoe and Golden Gate. The line underneath is blunt: macOS Intel is not supported. If you are on an Intel Mac, this tap is the wrong tool, and no formula name in the support table changes that. The second limit is architectural rather than platform-specific. Because switching versions means relinking, you cannot have [email protected] and [email protected] both answering to php at the same time. Projects that need per-directory PHP resolution are outside what this tap provides; the README's answer to multiple installed versions is a link command, not a version manager. The third limit is the development branches. [email protected] and [email protected] track 8.6.0-dev and 8.7.0-dev, and the README says 8.6 is built nightly. A nightly build moving under you is fine for compatibility testing and a poor fit for anything you need to reproduce byte for byte later.

How this compares with a per-project version manager

The real alternative is a PHP version manager that installs interpreters outside Homebrew and selects one per shell or per directory. The difference in approach is where the switching happens. This tap switches globally by rewriting symlinks through brew link, so the active PHP is a property of the machine. A version manager switches through a shim or an environment variable, so the active PHP is a property of the shell or the directory, and two projects can run different branches in two terminals at once. That is a genuine capability this tap does not offer. What the tap offers instead is integration with Homebrew's dependency graph and its prebuilt bottles, plus the ZTS and debug variants that a plain interpreter download does not give you. If your problem is "I need to compile a thread-safe extension", the tap is the shorter path. If your problem is "these two repositories need different PHP branches simultaneously", the tap is the wrong shape and a version manager is the right one. The README does not discuss version managers, so this comparison comes from what the tap's own commands can and cannot do.

Maintenance, licence, and what upgrading costs you

The repository is not archived, and the last push was on 2026-09-23, five days before this writing. The README carries build and test status badges and describes nightly builds for 8.6, so formulae are regenerated rather than hand-edited once and forgotten. That has a cost for you: because the tap tracks upstream patch releases, an upgrade can move you between patch versions without any change on your side. If you need a fixed patch, the README does not document how to hold one. The licence is MIT, which covers the formula code in this repository. It does not relicense PHP itself, which ships under its own terms, and it does not change Homebrew's licensing. The repository also contains a separate LICENSE_HOMEBREW file, suggesting Homebrew-derived material is tracked under its own terms. Read both files before redistributing anything from this tap; nothing here is legal advice.

Editorial conclusion

Adopt this tap if you develop on Apple silicon or Linux and need to switch between PHP branches, or need ZTS and debug builds for extension work. Do not adopt it if you are on macOS Intel, which the OS support table lists as unsupported, or if you want several PHP versions active simultaneously, since the workflow is link and relink. Before installing, check the PHP Support table for the exact formula name of your version and confirm your macOS release appears in the OS Support table.

Frequently asked questions

Which PHP versions does shivammathur/homebrew-php provide?

The PHP Support table lists formulae from [email protected] through [email protected], with 8.6.0-dev and 8.7.0-dev as development branches. Each version has four variants: the plain formula, -zts for thread safety, -debug for debug symbols, and -debug-zts for both.

How do I install PHP 8.4 with shivammathur/homebrew-php?

Add the tap with brew tap shivammathur/php and brew trust shivammathur/php, then install the versioned formula, for example brew install shivammathur/php/[email protected]. After installing you must link it with brew link --overwrite --force shivammathur/php/[email protected] and restart the terminal.

Can shivammathur/homebrew-php install multiple PHP versions at once?

You can install several versioned formulae side by side, and the README describes switching between them with brew link --overwrite --force. Only one is linked as php at a time, so two projects cannot use different branches in two terminals simultaneously through this tap alone.

Does shivammathur/homebrew-php work on Intel Macs?

No. The OS Support table lists macOS support for arm64 only, across Sequoia, Tahoe and Golden Gate, and states that macOS Intel is not supported. Linux is supported on both x86_64 and arm64.

Official sources

  1. Issues
  2. License: MIT
  3. Project website
  4. README
  5. shivammathur/homebrew-php on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/shivammathur-homebrew-php.svg)](https://hysenlabs.com/projects/shivammathur-homebrew-php)