brew tap shivammathur/php
PHP Support
| PHP Version | Formula |
|---|---|
| PHP 5.6 | php@5.6 |
| PHP 7.0 | php@7.0 |
| PHP 7.1 | php@7.1 |
| PHP 7.2 | php@7.2 |
| PHP 7.3 | php@7.3 |
| PHP 7.4 | php@7.4 |
| PHP 8.0 | php or php@8.0 |
| PHP 8.1.0-dev | php@8.1 |
| PHP 8.2.0-dev | php@8.2 |
OS Support
| Operating System | Architecture |
|---|---|
| Linux 4.18+ | x86_64 |
| macOS Catalina | x86_64 |
| macOS Big Sur | x86_64, arm64 |
| macOS Monterey | x86_64, arm64 |
On Linux, GLIBC 2.27 or newer is required, so distributions with Linux kernel 4.18 and newer are supported.
For example: Ubuntu 18.04, Debian 10, CentOS 8, Fedora 28, and newer versions of these distributions.
Usage
Prerequisites
- On macOS, install Xcode Command Line Utilities:
xcode-select --install- On Linux, install cURL and Git:
# Using APT
sudo apt-get install -y curl git
# Using Yum
sudo yum install -y curl git- Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"- If previously installed, update homebrew and the formulae:
brew update- If you have packages from old
homebrew/phptap, refer to this guide for removing them.
Add this tap
Fetch the formulae in this tap:
brew tap shivammathur/phpInstall PHP
See PHP Support for available formulae.
- For example, to install
PHP 7.4:
brew install shivammathur/php/php@7.4- After installing your have to link it:
brew link --overwrite --force php@7.4- Restart the terminal and test your PHP version:
php -vUpgrade your PHP version
You can upgrade your PHP version to the latest patch release.
For example, to upgrade PHP 7.4:
brew upgrade shivammathur/php/php@7.4Switch between PHP versions
- If you have multiple PHP versions installed, you can switch between them easily.
For example, to switch to PHP 7.4:
brew link --overwrite --force php@7.4- If you get a warning like below, then do as recommended:
Warning: Already linked: <Cellar Path>
To relink:
brew unlink <formula> && brew link <formula>brew unlink php@7.4
brew link --overwrite --force php@7.4Restart your webserver
If you are using Apache or Nginx with php-fpm, restart your webserver after any change in your PHP.
- For Apache (
httpd):
brew services restart httpd- For Nginx:
brew services restart nginxDebugging
-
Make sure you ran
brew updatebefore installing PHP. -
Run
brew doctorand fix the warnings it reports. -
Make sure homebrew has correct permissions.
sudo chown -R "$(id -un)":"$(id -gn)" $(brew --prefix)- If PHP is not working after a macOS update. Reinstall PHP along with its dependencies.
For example to reinstall PHP 7.4 and its dependencies:
brew reinstall $(brew deps shivammathur/php/php@7.4) shivammathur/php/php@7.4-
Check if your issue is a Homebrew's common issue.
-
If you are still facing an issue, please create a discussion thread here.
License
The code in this project is licensed under the MIT license. Please see the license file for more information.
This project has some dependencies, and their license can be found here.
Contributions
Contributions are welcome! Please see Contributor's Guide before you start. If you face any issues while using this tap or want to suggest a feature/improvement, create an discussion thread here.
Sponsors
We use MacStadium for our CI infrastructure.
This project is generously supported by many other users and organisations via GitHub Sponsors.


