Uncaught ErrorException: preg_match_all(): JIT compilation failed: no more memory - macos

I just upgraded my PHP on macOS from 7.2 to 7.3 and while trying to run composer update on a project of mine, I get the error;
PHP Fatal error: Uncaught ErrorException: preg_match_all(): JIT compilation failed: no more memory
I've run a few Google searches; it looks like the issue is new, and I couldn't find any working documentation online.
Is this an issue related to PHP 7.3 and Composer? If so, how do I resolve it? Thanks for your help in advance.

If pcre.jit = 0 pcre.jit=0 pcre.jit = Off in php.ini, not worked, try this:
I suppose you installed php 7.3 through homebrew.
If so, create a zzz-myphp.ini in /usr/local/etc/php/7.3/conf.d with the following content:
; My php.ini settings
; Fix for PCRE "JIT compilation failed" error
[Pcre]
pcre.jit=0
If this also doesn't work, uninstall php7.3 and install 7.2 or 7.1
brew uninstall php#7.3

Edit the following file
/usr/local/etc/php/7.3/php.ini
Find and change the pcre.jit variable
pcre.jit=0
If the issue remains
Try restarting your computer.

Related

Composer update or install issue

I have an web application which successfully run since august 2020. now i want to add milon barcode package and it successfully ok in local server that's why i need to run coposer install or update command in cpanel terminal. but there show some problem.
N.B Laravel version 5.8, composer version 2.0.6, php version 7.4.
when i try to run composer install it show error
PHP Fatal error: Uncaught ErrorException: proc_open(): unable to create pipe Too many open files in phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Application.php:952
when try to run composer update
Failed to download phpoption/phpoption from dist: getaddrinfo() thread failed to start
when try to run composer self-update
[Composer\Downloader\FilesystemException]
Filesystem exception:
Composer update failed: "/opt/cpanel/composer/bin/composer" could not be written.
rename(/opt/cpanel/composer/bin/composer): failed to open stream: Permission denied
You need to enable proc_open
Please Follow the Instruction Below in cPanel
Software > MultiPHP INI Editor > Editor Mode
Select your PHP version and search for (disable_functions)
disable_functions = "proc_open,..., ..."
Now remove (proc_open) from the list and save.
Otherwise, contact your hosting service provider to enable proc_open.
try using this command
composer update --no-scripts

Laravel error - Class setEventDispatcher does not exist

Short version
I'm getting this error, when I run php artisan serve and visit my home page:
ReflectionException (-1)
Class setEventDispatcher does not exist
Details
Laravel version: 5.6.39
Environment: local
OS: macOS Mojave 10.14.2
It started, when I got an error using npm (in another project), so I reinstalled Node (this way).
After doing that, then this project (in question) couldn't be started. I was getting this error, when running php artisan serve:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related
Referenced from: /usr/local/bin/php
Reason: image not found
That error was resolved by updating and upgrading brew.
Then I was capable of starting the project (php artisan serve). But when I visit the home page, this error was shown:
ReflectionException (-1)
Class setEventDispatcher does not exist
If I follow the stack trace, then I can see that it was this line (from my homeController) that triggered the error:
if( ! Auth::check() ){
return view( 'pages.home' );
}
If I commented that out, then the same error occured from another place, where the Auth-module was being used.
Here's the stack trace:
Does anyone know how to resolve this? I can't find any promising results on Google, - and I have no idea why this happens... :-/
Addition1
I tried composer clear-cache and deleting the vendor-folder, and then doing a composer install and the problem still occured.
I also checked my Service Providers, as Marcus suggested, - but I don't really know what to look for in there. It all looks pretty regular (no fancy if-statements or anything).
Addition2
I realized, that I couldn't connect to my database using Sequel Pro. And it was because Brew had updated my MySQL-version from 5.5 to 8.0.
That was resolved by doing something along these lines (I did a bunch of stuff, so I might be missing a coulple of steps):
brew unlink mysql
brew install mysql#5.7
brew switch mysql 5.7.21
brew link mysql
and I could then verify the version with mysql --version. I also had some permission issues with that MySQL-version-change, but I'm emitting that, so this doesn't get too long.
Addition3
I tried disabling the Laravel Debugbar (by deleting it from composer.json, deleting composer.lock and vendor and then running composer install). And that fixed it!! ... But!
When I later tried to install Barryvdh's IDE Helper, then the exact same error came back!?
I performed these three steps, to install the IDE Helper (and re-introduce the error):
Run this command from the root of my directory: curl https://gist.githubusercontent.com/barryvdh/5227822/raw/4be028a27c4ec782965bb8f2fdcb4c08c71a441d/_ide_helper.php -o _ide_helper.php
Add these lines to app/Provider/AppServiceProvider.php:
...
if ($this->app->environment() !== 'production') {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
Run this command: composer require --dev barryvdh/laravel-ide-helper
So I'm back at this error:
ReflectionException (-1)
Class setEventDispatcher does not exist
... The stack trace is identical to the one shown previously (sprung from Container.php).
Tried every solution, none of them worked.
Finally, i realised that when trying to upgrade php to 7.3.3 it was infact a network error that caused the fail. Read the logs, tried again, restarted valet and tried again.
It works now.
Upgrading to 7.3.3 was the solution indeed.
Thank you!
So this is what usually fixes it for me
Reinstall composer dependencies by removing vendor folder and composer.lock. Then run composer clear-cache and then composer install (this is usually the problem)
Check that all service providers are imported correctly in app.php under directory config
Make sure that your service providers are not importing something that does not exist, for example if you register a service provider in production but is only installed as dev:
if (env('APP_DEBUG')) {
$app->register(Barryvdh\Debugbar\LumenServiceProvider::class);
}
If you use valet, I solved it running
valet restart and all works fine.
cheers!
The fix for me was to update PHP to 7.3.3 and then restart valet. Apparently this was a bug with php 7.3
https://github.com/laravel/framework/issues/27052
Hope this helps
I got some idea... I've just run into this problem after reconfiguring my apache virtual host ports, so I restarted apache/httpd again, and the problem went away. Might it be related with the server environment?
I am facing the same issue in mac book pro. My system configuration is PHP 7.3, MySQl and I use SQL Pro. I have implemented all the above methods but nothing gets worked.
The issue is still a mystery for me but for temporary I have solved this issue using
artisan command as bellow.
php artisan serve
Its Allow me to run the project on http://localhost:8000
Hope this can help to solve this issue.
Try to restart PHP. When I reboot my Mac, then this happens. After restarting PHP everything starts to work.
sudo brew services restart nginx

I get an error when installing laravel or when I try updating composer. How do I resolve it?

I get this error
"require(/var/www/html/data_security/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/data_security/bootstrap/autoload.php on line 17"
when installing laravel or when I try updating composer. How do I resolve it?
For fresh installation you will need to run composer install instead of composer update. I faced similar issue and composer install did the trick for me.

Composer Download Error

i got this error when i'm trying to install composer for laravel framework :
"Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl"
i tried much but i don't know what should i do right now ?
i got win 8.1 , wamp 1.7 , php 5.4
open C:\wamp\bin\php\php5.4.12\php.ini & C:\wamp\bin\apache\Apache2.4.4\bin\php.ini
Find the line ;extension=php_openssl.dll and remove the semicolons ';'.
The line should look like extension=php_openssl.dll.

Laravel upgrade to 4.2 - mcrypt extension required

I have problems when trying to update laravel 4.1 to 4.2.
I started that project on ubuntu, then got a new macbook pro and it looks like I'm missing something.
I'm using XAMPP 1.8.3
When I
composer update
I get the following error
Mcrypt PHP extension required.
Script php artisan clear-compiled handling the post-update-cmd event returned with an error
After few googling, found homebrew, then it's easy
brew install mcrypt
but I get the following warning
Warning: mcrypt-2.6.8 already installed
Any ideas?
Assuming your macbook pro is running Mavericks, the problem is most likely in your $PATH variable. The php command defaults to the built in php that ships with your mac. You can verify this by entering in terminal echo $PATH;
If it points to /usr/bin:/bin/usr/bin:/usr/local/bin then the problem is here because the native mac php does not include mcrypt. Add your XAMP PHP to your paths variable should solve the problem,
export PATH=$PATH:\path\to\xamp\bin\php5.ver\bin

Resources