appstract / laravel-opcache

Laravel Package for OPcache
MIT License
1.33k stars 118 forks source link

Not compatible with php artisan optimize #134

Open Kryptonien opened 3 years ago

Kryptonien commented 3 years ago

Hi,

I noticed the lib doesn't work if you're compiling with php artisan optimize.

As a workaround i'm doing

php artisan optimize clear
php artisan opcache:clear
php artisan optimize

You might need to declare a route somewhere in your package.

hakimzulkufli commented 2 years ago

This ticket sounds too vague but I'm assuming it's related to the errors when running php artisan opcache:compile after php artisan optimize. If not, I will open a separate ticket. I probably should since I'm using php 7.2 and laravel-opcache 3.2.1.

Running php artisan optimize will also compile the Blade views, like php artisan view:cache. Because of this, laravel-opcache will not able to compile the views into OPcache.

In my case, the following error occurred when running php artisan opcache:compile after php artisan optimize:

-- storage/framework/views/17d49dbffa9f42d427d8bc281997de1c39cc043e.php

syntax error, unexpected 'Im' (T_STRING), expecting ',' or ')'

I have to run:

php artisan optimize
php artisan view:clear
php artisan opcache:compile

...in that order. I'm not sure if this affects anything or if compiling the views are needed when using laravel-opcache.