Upgrading PHP to 8 on macOS with Homebrew and Configuring Common Extensions

This guide walks you through updating Homebrew, upgrading PHP to version 8 on macOS, verifying the installation, restarting web servers, installing and managing PECL extensions, and handling Laravel Valet-specific steps to ensure a fully functional PHP 8 environment.

php Courses
php Courses
php Courses
Upgrading PHP to 8 on macOS with Homebrew and Configuring Common Extensions

This article explains how to upgrade PHP to version 8 on macOS using Homebrew, verify the installation, and configure common extensions.

Update Homebrew brew update Upgrade PHP brew upgrade php Check the installed PHP version php -v Restart your web server

sudo nginx -s reload
sudo apachectl restart

Create a simple index.php containing phpinfo(); and access it through your web server to confirm the version shows 8.0.x.

Laravel Valet users

Run the following commands to update Valet and its dependencies:

composer global update
valet install

After upgrading, restart Valet: valet restart Install common PECL extensions

pecl install imagick
pecl install redis
pecl install xdebug

List installed extensions: pecl list Search for other extensions, for example PDF libraries: pecl search pdf Configure extensions in php.ini

Add the following lines to the appropriate php.ini file (you can locate it with php --ini):

extension="redis.so"
extension="imagick.so"
zend_extension="xdebug.so"

After modifying php.ini, restart the web server (or Valet) again.

If an extension fails to load, you can reinstall it:

pecl uninstall imagick
pecl install imagick

Final step

Test your applications and upgrade them for PHP 8 compatibility. For more PHP 8 features, refer to the dedicated PHP 8 section.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PHPWeb serverHomebrewPECLLaravel Valet
php Courses
Written by

php Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.