Error: php@7.3 has been disabled because it is a versioned formula
When you run brew install php@7.3, Homebrew might immediately reject your request with the message: "Error: php@7.3 has been disabled because it is a versioned formula!" This error isn't a bug in your environment; it's a deliberate policy enforced by the core Homebrew team. To resolve this, you need to understand how Homebrew manages its package versions and why dropping support for specific PHP versions like 7.3 occurred.
The Shift to Versioned Formulas
Historically, Homebrew allowed users to install multiple versions of the same software simultaneously using versioned formulas (prefixed with an @ symbol). This was useful in the early days when developers needed to run legacy applications requiring older runtimes. However, this approach introduced significant complexity into package management. Maintaining dozens of distinct versions for every dependency created a fragmented ecosystem where updating one version could inadvertently break another application relying on a specific iteration of the same tool.
Homebrew has since transitioned away from versioned formulas for many packages, including PHP. By default, Homebrew now installs only the latest stable version of a package (e.g., php) and manages it as a single entity. When you attempt to install a deprecated version like php@7.3, the formula is marked as disabled in the core repository. This ensures that your system doesn't accumulate obsolete binaries that might lack security patches or compatibility with modern dependencies.
How to Install PHP on Homebrew
Since direct installation of older versions is blocked, the standard workflow for managing PHP on macOS involves using the non-versioned formula. If you simply run:
brew install php
Homebrew will fetch and install the most recent stable release available. This version comes with support for modern PHP extensions and aligns with current best practices for web development.
If you need to manage multiple PHP versions in your environmentâfor instance, switching between 8.1 and 8.2âyou should instead use PHP Homebrew or a dedicated PHP version manager like php-build or rbenv, rather than relying on the @ syntax within standard Homebrew formulas. These tools allow you to install multiple versions as separate packages (e.g., php81, php82) and switch between them using environment variables in your shell configuration.
Checking Available Versions
To see what PHP versions are currently supported by Homebrew, you can run:
brew formulae | grep php
Or more specifically:
brew search php
This will list all available PHP-related formulas and their current status. You'll notice that versioned entries like php@7.3 are absent or explicitly disabled, while newer versions appear as standard packages.
Why This Matters for Developers
For Laravel developers specifically, using the latest stable PHP version is crucial. Many modern Laravel features, including improved type inference, performance optimizations, and security enhancements, require PHP 8.x. Attempting to force an older version like 7.3 can lead to incompatibilities with Composer packages, database drivers, and other dependencies that assume a newer runtime environment.
If you're building applications for legacy systems where PHP 7.3 is strictly required, consider using Docker containers or VMs rather than forcing Homebrew to maintain outdated versions. This keeps your development machine clean and ensures your local setup matches production environments more closely.
Final Recommendation
The error you encountered is a safeguard against maintaining an increasingly complex and insecure software stack. Embrace the shift toward versioned-free package management by using the latest PHP release or adopting external version managers designed for this purpose. This approach keeps your development environment streamlined, secure, and compatible with modern web frameworks like Laravel.