How to upgrade to PHP 7.4 on MacOS with Brew?
PHP 7.4 is out and this short guide offers steps to upgrade PHP installation on your MacOS to the latest. Follow these steps -
Step 1: Update Brew
Step 2: Upgrade PHP
brew upgrade php
Step 3: Verify the php version
This step checks currently running version of PHP on your MacOS.
Step 4: Restart web server
sudo nginx -s reload OR brew services restart nginx
Now, run the good 'ol phpinfo() to let php output its own configuration information. Put that code in a phpinfo.php OR index.php of your project and access it from the web browser. Make sure that the PHP version is now 7.4.x
PHP 7.4 comes with an interesting set of new features. Arrow functions will help you clean up your code and preloading, if your hosting environment allows it - can massively boost your code's performance.
PHP community's long standing demands have been addressed as well. PHP 7.4 brings typed properties and improved type variance. The spread operator can now be used in arrays.
If you have questions about installing PHP 7.4 on MacOS with Homebrew, post them below.Posted in: #PHP
If you are a Laravel valet user, above steps won't be sufficient. Laravel valet currently does not support the latest additions in PHP 7.4. You will have to apply a temporary fix as follows -
Step 5: Update composer
composer global update
Now, we'll have to add php 7.4 to the list of supported versions. In order to do that follow these steps:
Step 6: Update Brew.php
"sudo nano ~/.composer/vendor/laravel/valet/cli/Valet/Brew.php"
Step 7: Add support for PHP 7.4
Look for "SUPPORTED PHP VERSIONS and add email@example.com to the list.
Step 8: Install Valet
These steps should help you get Laravel Valet running with latest PHP 7.4.x on MacOS. I hope this helps. Questions and comments are welcome.
Brew does not support installing most common php extensions anymore. You can install them with PECL. The format to install is pecl install
xdebug installation is bit tricky. Let me know if anyone wants help with it. You can check all your PECL extensions by running pecl list command.
Mohit, my xdebug installation with brew is failing on PHP 7.4 Just wondering if the latest xdebug is compatible with latest PHP 7.4.x and if there are any extra settings required. Right now, if I enable the xdebug helper in Chrome and initiate a request; it does not stop at the breakpoints.
I'm wondering if I'm missing any step in my PHP install?