There’s excitement in the developer community with the release of PHP 8 on November 26, 2020. The major release brings with it new features and performance improvement for applications developed with PHP technology. Likewise, developers and business owners can expect deprecation warnings and errors, so they have to make some changes in the application’s codebase to get it running on PHP 8.
Upgrade with Homebrew
Open your terminal and make sure brew is up-to-date:
Now, you can upgrade the current PHP version to the latest release. Upgrading support using the built-in PHP recipe, or you can use this tap shivammathur/homebrew-php
. We recommend using the tap since you can install multiple PHP versions allowing you to switch when needed.
Upgrading normally
Upgrading with shivammathur/homebrew-php
You can switch between versions using the following command:
You can learn more about the tap here.
Verify the current version:
Restart Apache or Nginx:
You can verify your local web server uses PHP 8 by adding the code below in info.php
:
Note: Developers with Laravel Valet should follow the steps below to ensure the web server works properly.
Valet
Developers with Laravel Valet should follow the steps below to ensure the web server works properly.
Now, you can install valet by running:
Extensions
You can install PHP extensions with pecl
. We prefer using Imagick
, Redis
and Xdebug
:
You can run pecl list
to see installed extensions:
You can search for other extensions using pecl search
:
Don’t forget to restart web server after installing new packages:
For Laravel Valet, you can restart by using the following command:
Ensure you installed the extensions correctly:
There are two fixes for extensions that didn’t load properly.
First, make sure the extensions are added in the correct ini
file. You can run php –ini to know which file is loaded:
Check the ini
file:
Reminder: you don’t have to restart Nginx, Apache or Valet if you testing installed extension via the CLI especially when you make changes to the ini
settings.
The second thing you can do is to reinstall extensions individually if you are updating from an older PHP version.
Last Note
Don’t forget to check your project(s) is compatible with PHP 8. Need help upgrading your application(s) to PHP 8? Don’t hesitate to send us a message to see how we can help.