Jump to bottom
Shivam Mathur edited this page
Nov 12, 2021· 2 revisions
Pages 2
Home
Cleanup
- Remove PHP packages
Remove PHP packages
- Remove PHP from the Homebrew Cellar:
rm -rf $[brew --cellar]/php
- Remove old PHP Launch Agents and daemons, if present:
rm -f ~/Library/LaunchAgents/homebrew.mxcl.php* rm -f /Library/LaunchAgents/homebrew.mxcl.php* rm -f /Library/LaunchDaemons/homebrew.mxcl.php*
- Remove the deprecated
homebrew/php
tap, if present:
brew untap homebrew/php
- Remove the deprecated
exolnet/deprecated
tap, if present:
brew untap exolnet/deprecated
- Run brew cleanup:
brew cleanup
brew tap shivammathur/php
PHP Support
PHP 5.6 |
| -debug
|
PHP 7.0 |
| -debug
|
PHP 7.1 |
| -debug
|
PHP 7.2 |
| -debug
|
PHP 7.3 |
| -debug
|
PHP 7.4 |
| -debug
|
PHP 8.0 |
| -debug
|
PHP 8.1 | php or
| php-debug or -debug
|
PHP 8.2.0-dev |
| -debug
|
PHP 8.3.0-dev |
| -debug
|
Debug versions
For each PHP version there is an extra formula with debug symbols enabled. This version can be used when building or debugging PHP extensions and are not recommended for production usage.
OS Support
Linux | x86_64
|
macOS Catalina | x86_64
|
macOS Big Sur | x86_64 , arm64
|
macOS Monterey | x86_64 , arm64
|
Usage
Prerequisites
- On macOS, install Xcode Command Line Utilities:
- 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 //raw.githubusercontent.com/Homebrew/install/master/install.sh]"
- If previously installed, update homebrew and the formulae:
- If you have packages from old
homebrew/php
tap, refer to this guide for removing them.
Add this tap
Fetch the formulae in this tap:
brew tap shivammathur/php
Install PHP
See PHP Support for available formulae.
- For example, to install
PHP 8.0
:
brew install shivammathur/php/
- After installing you have to link it:
brew link --overwrite --force shivammathur/php/
- Restart the terminal and test your PHP version:
Upgrade your PHP version
You can upgrade your PHP version to the latest patch release.
For example, to upgrade PHP 8.0
:
brew upgrade shivammathur/php/
Switch between PHP versions
- If you have multiple PHP versions installed, you can switch between them easily.
For example, to switch to PHP 8.0
:
brew link --overwrite --force shivammathur/php/
- If you get a warning like below, then do as recommended:
Warning: Already linked:
To relink:
brew unlink && brew link
brew unlink brew link --overwrite --force shivammathur/php/
Restart 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 nginx
Debugging
Make sure you ran
brew update
before installing PHP.Run
brew doctor
and 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 8.0
and its dependencies:
brew reinstall $[brew deps shivammathur/php/] shivammathur/php/
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
In addition to GitHub Actions, we use MacStadium and Scaleway for our CI infrastructure.
This project is generously supported by many other users and organisations via GitHub Sponsors.
Related Projects
- shivammathur/homebrew-extensions
- shivammathur/setup-php
Dependencies
- Homebrew/brew
- Homebrew/homebrew-core
- Homebrew/actions