By continuing your visit to this site, you accept the use of cookies. Read more

Scout APM helps PHP developers pinpoint N+1 queries, memory leaks & more so you can troubleshoot fast & get back to coding faster. Start your free 14-day trial today .

« back — written by Brent on March 21, 2019

Upgrade to PHP 7.3 with Homebrew on Mac

# Upgrading with Homebrew

Start by making sure brew is up-to-date:

brew update

Next, upgrade PHP:

brew upgrade php

Check the current version by running php -v :

php -v

Restart Nginx or Apache:

sudo nginx -s reload

sudo apachectl restart

And make sure that your local web server also uses PHP 7.3 by visiting this script:

phpinfo(); die ();

The version should show 7.3.x .

Note: if you're using Laravel Valet, please keep on reading, you need some extra steps in order for the web server to properly work.

# JIT compilation failed error

You might notice this error showing up when running PHP scripts, for example: composer global update .

PHP Warning: preg_match(): JIT compilation failed

This is due to a PHP 7.3 bug, and can easily be solved by making a change in your PHP ini file.

If you don't know which ini file is used, you can run the following:

php --ini

Solving the above error can be done by manually disabling the pcre.jit option in our ini file.

# /usr/local/etc/php/7.3/php.ini - ;pcre.jit=1 + pcre.jit=0

You may have heard of Homebrew dropping support for PHP extensions, this should now be done with PECL. I personally use Imagick, Redis and Xdebug.

They can be installed like so:

pecl install imagick pecl install redis pecl install xdebug

You can run pecl list to see which extensions are installed:

pecl list

You can search for other extensions using pecl search :

pecl search pdf

Make sure to restart your web server after installing new packages:

sudo nginx -s reload

sudo apachectl restart

If you're using Laravel Valet, you should do the following steps to upgrade it:

composer global update

Now run valet install :

valet install

Note that if you're upgrading Valet from 2.0 to 2.1, your Valet config folder will automatically be moved from ~/.valet to ~/.config/valet .

If you have any paths pointing to this folder, you'll have to update them. I, for example, have a custom Nginx config file for one of my local sites. This config file contained absolute paths to the Valet socket. These had to be manually changed.

If you're running into problems with Nginx, you can check out the errors in the logs:

cat /usr/local/var/log/nginx/error.log

If any changes were made to your Valet config, you should restart it:

valet restart

# Last step

Finally you should test and upgrade your projects for PHP 7.3 compatibility.