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.
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 restartCreate 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 installAfter upgrading, restart Valet: valet restart Install common PECL extensions
pecl install imagick pecl install redis pecl install xdebugList 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 imagickFinal step
Test your applications and upgrade them for PHP 8 compatibility. For more PHP 8 features, refer to the dedicated PHP 8 section.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
php Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
