1. Home >
  2. Apps >
  3. Groups >

How to upgrade to PHP 7.4 on MacOS with Brew?

Question asked by Kaustubh Katdare in #PHP on Dec 2, 2019
Kaustubh Katdare
Kaustubh Katdare · Dec 2, 2019
Rank A1 - PRO

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

brew update

Step 2: Upgrade PHP

brew upgrade php

Step 3: Verify the php version

php -v

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
Kaustubh Katdare
Kaustubh Katdare · Dec 2, 2019
Rank A1 - PRO

Update:

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 php@7.4 to the list.

Step 8: Install Valet

valet install

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.

Mohit G
Mohit G · Dec 2, 2019
Rank D3 - MASTER

Brew does not support installing most common php extensions anymore. You can install them with PECL. The format to install is pecl install . For example pecl install xdebug

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.

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up