Open wilbur-yu opened 3 years ago
This seems to happen at https://github.com/appstract/laravel-opcache/blob/d2ce88cddda6af54c14d1f9ceaaf94b54f38f9d3/src/OpcacheClass.php#L70
because polyfill files that require php 8 syntax are being parsed.
For now I've simply run php artisan vendor:publish --provider="Appstract\Opcache\OpcacheServiceProvider" --tag="config"
to publish the config file and added the following to exclude:
'exclude' => [
...
...
'symfony/polyfill-ctype',
'symfony/polyfill-iconv',
'symfony/polyfill-intl-grapheme',
'symfony/polyfill-intl-idn',
'symfony/polyfill-intl-normalizer',
'symfony/polyfill-mbstring',
'symfony/polyfill-php80'
],
Not a definitive solution but for now it works!
Any updates soon @ovanschie ? :)
The easy but not very viable solution is use php 8.
I've spent some time digging into this today, and this appears to impact anyone running on PHP 7.x (7.4, in my case):
When iterating over the found files, opcache_compile_file()
trips up on the bootstrap80.php
files included within the various symfony/polyfill-* packages, as they use PHP 8.x-specific syntax (the polyfill packages themselves are a dependency of swiftmailer/swiftmailer, which is itself a dependency of laravel/framework).
Normally this wouldn't be a problem, as the Symfony packages only load these files when running on PHP 8.x. However, the list of files doesn't know about this, so we attempt to inject PHP 8.x syntax into a PHP 7.x OPcache and everything goes sideways.
The solution @lorenzocattaneo works as a short-term fix, but ultimately it's excluding everything in those symfony/polyfill-* packages from getting pre-loaded. @wojo1206's work in #125 would let us target specific files (as opposed to whole directories), which would be beneficial, but ultimately some better error handling within OpcacheClass::compile()
is needed to prevent issues like this from breaking the whole process.
php version: 7.4.14