How to Install/Upgrade PHP 8.3 on MacOS with Homebrew

Published On22 Nov 2023

How to install or upgrade to PHP 8.3 on MacOS with Homebew

With a handful of new features such as typed class constants, granular Exceptions in the DateTime extension, the new json_validate function, functionality changes and improvements, and deprecations, PHP 8.3 is 2023's major update to PHP. This article explains how to install or upgrade to PHP 8.3 on macOS using Homebrew.

Shivam Mathur maintains two Brew taps, shivammathur/php and shivammathur/extensions that contain precompiled PHP 8.3 packages (bottles) which are kept up to date, making it convenient to install PHP 8.3 and several PHP core and PECL extensions using Homebrew.


In the macOS terminal, run the following commands to quickly install PHP 8.3 using Homebrew. Homebrew must be installed first.

For detailed steps, see jump to the Detailed Installation/Upgrade guide.

# Add the PHP and PHP Extension taps
brew tap shivammathur/php
brew tap shivammathur/extensions

# Install PHP 8.3
brew install shivammathur/php/php@8.3

# Link PHP 8.3 CLI executable as `php`
brew link --overwrite --force shivammathur/php/php@8.3

# Test installation
php -v

Detailed Installation/Upgrade guide to install PHP 8.3 on macOS

1. Prerequisites

Make sure to have Homebrew installed. This was tested on macOS macOS Monterey, Ventura, and Sonoma.

Installing the PHP 8.3 as shown in the rest of the article requires Homebrew and the two Homebrew taps maintained by Shivam Mathur.

2. List and keep note of existing PHP packages

When upgrading an existing PHP version, the following command lists all Brew packages, filters them for PHP-related words, and saves them to a packages.txt file. This file can then come in handy later to install the same set of PHP packages for PHP 8.3.

This step is not necessary when installing PHP on a new system.

brew list --full-name | grep -E "php|shivammathur/extensions" | tee packages.txt

3. Add New Taps to Homebrew

brew tap shivammathur/php
brew tap shivammathur/extensions

4. Install PHP 8.3

brew install shivammathur/php/php@8.3
brew link --force --overwrite shivammathur/php/php@8.3

This install PHP with several core extensions. It is not possible to customize the list of extensions included without recompiling PHP.

5. Additional PHP Extensions

The shivammathur/extensions tap contains several PECL extensions ready to install.

# Install xdebug for PHP 8.3
brew install shivammathur/extensions/xdebug@8.3

See the complete list of available extensions here. For convenience, some of the most popular PECL extensions are listed below:

Extension Name
Xdebug shivammathur/extensions/xdebug@8.3
APCu shivammathur/extensions/apcu@8.3
IMAP shivammathur/extensions/imap@8.3
PCOV shivammathur/extensions/pcov@8.3
Redis shivammathur/extensions/redis@8.3
Swoole shivammathur/extensions/swoole@8.3
YAML shivammathur/extensions/yaml@8.3

6. Web Server Integrations

If PHP is integrated with a web server, restart/reload the web server to reload the changes with the new PHP FPM version.

  • Apache: brew services restart httpd
  • Nginx: brew services restart nginx
  • Caddy: caddy reload

7. Test PHP 8.3 Installation

Running php -v in the terminal should show something like this:

php -v output
Calling `php -v` displays the PHP version number and build date.

8. Migrate Configuration

This step only applies when updating to PHP 8.3 from an older PHP version

The configuration files for the PHP 8.3 are located at /opt/homebrew/etc/php/8.3. Existing PHP installations should also be in the /opt/homebrew/etc/php directory.

Do not copy existing PHP INI files to /opt/homebrew/etc/php/8.3. While it may work when upgrading from PHP 8.2 or a recent version, manually copying the INI directives is recommended.

See What's new and changed in PHP 8.3 to see the deprecated INI directives and the new INI directive added in PHP 8.3.

9. Remove old PHP Versions

This step only applies when updating to PHP 8.3 from an older PHP version

To remove old PHP versions, run brew uninstall with the PHP package name and version.

PHP installed from Brew's core packages

brew uninstall php@8.2

PHP installed from shivammathur/php tap

brew uninstall shivammathur/php/php@8.1

Further Resources

Recent Articles on PHP.Watch

All ArticlesFeed 
How to fix `mysql_native_password` not loaded errors on MySQL 8.4

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to fix the SQLSTATE[HY000] [1524] Plugin 'mysql_native_password' is not loaded errors caused in MySQL 8.4 no longer enabling the mysql_native_password plugin by default.
How to fix PHP Curl HTTPS Certificate Authority issues on Windows

How to fix PHP Curl HTTPS Certificate Authority issues on Windows

On Windows, HTTPS requests made with the Curl extension can fail because Curl has no root certificate list to validate the server certificates. This article discusses the secure and effective solutions, and highlights bad advice that can leave PHP applications insecure.
AEGIS Encryption with PHP Sodium Extension

AEGIS Encryption with PHP Sodium Extension

The Sodium extension in PHP 8.4 now supports AEGIS-128L and AEGIS256 Authenticated Encryption ciphers. They are significantly faster than AES-GCM and CHACHA20-POLY1305. This article benchmarks them and explains how to securely encrypt and decrypt data using AEGIS-128L and AEGIS256 on PHP.
Subscribe to PHP.Watch newsletter for monthly updates

You will receive an email on last Wednesday of every month and on major PHP releases with new articles related to PHP, upcoming changes, new features and what's changing in the language. No marketing emails, no selling of your contacts, no click-tracking, and one-click instant unsubscribe from any email you receive.