group-icon
PHP Programming
Group for all things PHP, Coding Help, Problems and Solutions
104 Members
Join this group to post and comment.
31 Jan 2019

Fix preg_match(): JIT compilation failed error with Composer and PHP 7.3

I recently upgraded my development machine from PHP 7.2 to PHP 7.3. While installing Composer and some of the packages on my development server, I faced the following error -

preg_match(): JIT compilation failed 

It was followed by several lines that looked like this:-

Warning: preg_match(): JIT compilation failed: no more memory in phar

I've done installations several times and have never faced this issue. Upon investigating, I found out that the issue is common with Composer and running the latest PHP 7.3. However there's an easy fix -

Run the following commands:

  1. Determine which PHP version is currently being loaded by running php -v on the command prompt. Then run php --ini command which will tell you which configuration file (.ini) is being loaded by current setup. 
  2. It'd be similar to /usr/local/etc/php/7.3
  3. Edit this file by typing sudo nano /usr/local/etc/php/7.3

Once the .ini file is opened in the editor, you will have to search for "pcre.jit". You may do so by hitting CTRL+W keys on your keyboard and then entering pcre.jit, and then hit enter. 

Remove the comma before pcre.jit=1 and set it to pcre.jit=0. Then exit and reload php. If you installed it via brew, you could simply do brew services restart php

You may then run your composer and it should work without any issues. I hope this helps.