Upgrading to PHP 8 using Homebrew on Mac
This article is translated from: https://stitcher.io/blog/php-8-upgrade-mac
Upgrade with Homebrew
First make sure Brew is up to date:
1 |
|
Next, upgrade PHP:
1 |
|
Check the current version by running php -v:
1 |
|
Restart Nginx or Apache:
1 2 |
|
and make sure your local web server is also using PHP 8 by accessing the following script:
1 2 |
|
The version should show 8.0.x.
NOTE: If you are using Laravel Valet, please read on, you will need some extra steps to get your web server working properly.
Valet
If you are using Laravel Valet, you should perform the following steps to upgrade it:
1 |
|
Now run valet install:
1 |
|
Extension
PHP extensions are installed using pecl. Personally I use Imagick, Redis and Xdebug. They can be installed like this:
1 2 3 |
|
You can run pecl list to see which extensions are installed:
1 2 3 4 5 6 7 |
|
You can search for other extensions using pecl search:
1 2 3 4 5 6 7 |
|
Install After the new package, make sure to restart the web server:
1 2 |
|
If you are using Laravel Valet, you should restart it as well.
1 |
|
Make sure all extensions are installed and loaded correctly by checking your PHP web server and CLI installation:
1 2 |
|
If your extensions are not loading correctly, there are two simple fixes.
First, make sure you add the extension to the correct ini file. You can run php --ini to find out which file was loaded:
1 2 3 4 5 |
|
Now check the ini file:
1 2 3 |
|
Note that if you are testing an installed extension via the CLI, No need to restart nginx, apache or Valet when changing ini settings.
If you are updating from an older PHP version that also uses pecl to install extensions, you can do the second thing. is to reinstall each extension individually.
1 2 |
|
Final Step
Finally, you should test and upgrade your project for PHP 8 compatibility.
For more PHP8 related features, please visit the PHP8 special column!
The above is the detailed content of Upgrading to PHP 8 using Homebrew on Mac. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

