Hi,
installed a fresh prestashop 1.7.6 and transferred my old shop's data to it from 1.7.3
Everything seems working well, after I installed memcached I got 500 error during debug in vendor/symfony/symfony/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php stating OPcache is not enabled.
I contacted my hosting service, and they confirmed it was enabled, they also did all necessary checks on their side.
They said OPcache is normally meant to work with PHP-PHP-FPM, but when I enable it, I get a total blank page 500 error.
I can also see here opache is enabled on server end.
To Reproduce
Steps to reproduce the behavior:
lost access to BO, had to intervene in config /defines.php to regain access.
Screenshots
If applicable, add screenshots or screenrecords to help explain your problem.
PrestaShop version: 1.7.6
PHP version: php7.2
Hi @lordchukz,
Thanks to download this module
opcache.zip
to check if the opcache is enabled or not on your server.
If it is not enabled, you should have this
If it is enabled
In the meantime, you can follow this documentation: https://devdocs.prestashop.com/1.7/scale/optimizations/#opcache to edit your opcache configuration
Thanks!
Thanks a lot,
Unfortunately it gave me this error: Fatal error: Cannot use variable $request twice in /home/lords/public_html/modules/opcache/opcache/routes.php on line 13
Would you know by chance why?
Regards.
On 27 Aug 2019, at 10:46, khouloudbelguith notifications@github.com wrote:
Hi @lordchukz,
Thanks to download this module
opcache.zip
to check if the opcache is enabled or not on your server.
If it is not enabled, you should have thisIf it is enabled
In the meantime, you can follow this documentation: https://devdocs.prestashop.com/1.7/scale/optimizations/#opcache to edit your opcache configuration
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
@lordchukz, I just checked this module & it is well working in my case without errors.
I think you have some issues with the opcache on your server.
Thanks to check with your host & feedback.
Ok, thanks. Will do and get back soonest. regards.
On 27 Aug 2019, at 15:41, khouloudbelguith notifications@github.com wrote:
@lordchukz https://github.com/lordchukz, I just checked this module & it is well working in my case without errors.
I think you have some issues with the opcache on your server.
Thanks to check with your host & feedback.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270?email_source=notifications&email_token=AI2BG75HTEVFRIG3334ZSI3QGUVJPA5CNFSM4IQABDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5HYWWA#issuecomment-525306712, or mute the thread https://github.com/notifications/unsubscribe-auth/AI2BG7YRWDVY355SMNG3LOLQGUVJPANCNFSM4IQABDWA.
@lordchukz, thanks!
Waiting for your feedback.
Hi, I removed the extra $request from the route file and was able to activate module.
In module panel, opcache is enabled, but when I debugged, same error appeared. I think it has more to do with Symphony.
In opcache module configuration, got these notice:
Notice: Undefined index: opcache.load_comments in /home/lords/public_html/modules/opcache/opcache/src/OpCacheGUI/OpCache/Configuration.php on line 82
Notice: Undefined index: opcache.fast_shutdown in /home/lords/public_html/modules/opcache/opcache/src/OpCacheGUI/OpCache/Configuration.php on line 83
Any help? thanks.
On 27 Aug 2019, at 15:45, khouloudbelguith notifications@github.com wrote:
@lordchukz, thanks!
Waiting for your feedback.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
@lordchukz, could you please try to create the PHP info script on your server & check the opcache on your server.
opcache.fast_shutdown =0
in my case.
Thanks!
Here they are, also is attached of opcached configuration panel.
Also the cached scripts showing are not updated life, and they are all direct from root directory, not from life site.. is this correct?
On 27 Aug 2019, at 16:48, khouloudbelguith notifications@github.com wrote:
@lordchukz https://github.com/lordchukz, could you please try to create the PHP info script on your server & check the opcache on your server.
https://user-images.githubusercontent.com/16067358/63781602-e8c60880-c8e1-11e9-9e72-519628fe1d50.png
opcache.fast_shutdown =0 in my case.Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270?email_source=notifications&email_token=AI2BG73MEYIIIRZVSZ65ZETQGU5CJA5CNFSM4IQABDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5H72XQ#issuecomment-525335902, or mute the thread https://github.com/notifications/unsubscribe-auth/AI2BG72RJXE6B55PUBJHUWDQGU5CJANCNFSM4IQABDWA.
@lordchukz, there are no images attached here.
You need to connect on GitHub & upload the images here.
Thanks!
opsss... my bad.. first time, sorry.
@lordchukz, thanks for your feedback.
As attached, the opcache is enbaled on your server.
Could you please try to clear cache manually by deleting all the folder into var/cache (prod & dev).
Thanks to check by enabling the debug mode and feedback.
Sorry, didn’t get this one.. I should delete all folders in the var/cache. Right?
On 27 Aug 2019, at 17:31, khouloudbelguith notifications@github.com wrote:
@lordchukz, thanks for your feedback.
As attached, the opcache is enbaled on your server.Could you please try to clear cache manually by deleting all the folder into var/cache (prod & dev).
Thanks to check by enabling the debug mode and feedback.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
@lordchukz, yes all folder into /var/cache (prod & dev folders).
Thanks!
Done, no change.. giving same error.
Symfony\Component\Cache\Exception\
CacheException
in vendor/symfony/symfony/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php (line 32)
* @throws CacheException if OPcache is not enabled */ public function __construct($namespace = '', $defaultLifetime = 0, $directory = null) { if (!static::isSupported()) { throw new CacheException('OPcache is not enabled'); } parent::__construct('', $defaultLifetime); $this->init($namespace, $directory); $e = new \Exception();
@lordchukz, could you please check with your host again if they've disabled the opcache commands?
Thanks!
Ok, I will,
I just feel it is activated only for cpanel and not for prestashop files.
Will update you asap.
On 27 Aug 2019, at 18:28, khouloudbelguith notifications@github.com wrote:
@lordchukz https://github.com/lordchukz, could you please check with your host again if they've disabled the opcache commands?
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270?email_source=notifications&email_token=AI2BG755UJPYVZTQHWG3GQLQGVI2JA5CNFSM4IQABDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5IKQTI#issuecomment-525379661, or mute the thread https://github.com/notifications/unsubscribe-auth/AI2BG727RN6HNDQZF4V7DZDQGVI2JANCNFSM4IQABDWA.
Hi, got this feed back from the host.
Opcache is still enabled when checking the configuration files and PHP info. We have not disabled opcache commands in any way.
The php.ini file where it is enabled has the below configurations which includes all the ones on their page from before as well as the one new "opcache.fast_shutdown=0" suggested by the person on github.
The site is using php72 so these opcache directives are configured in that global php.ini.
[root@server:/root]$ grep -v '^\s$\|^#\|^;\|^\s#' /opt/cpanel/ea-php72/root/etc/php.d/10-opcache.ini
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=20000
opcache.use_cwd=1
opcache.fast_shutdown=0
opcache.enable_file_override=1
opcache.blacklist_filename=/opt/cpanel/ea-php72/root/etc/php.d/opcache*.blacklist
opcache.huge_code_pages=0
opcache.validate_permission=1
[root@server:/root]$
Comparing from their phpinfo page screenshots and yours they look identical from what I can tell visually. If any changes need made please let us know and we can modify this file as required.
Please find the pdf in attached.
thanks.
phpinfo().pdf
@lordchukz, you have some missing name in your oPcache configuration
You can follow this link: https://www.php.net/manual/en/opcache.configuration.php
Thanks!
Hi,
Made the following changes, but nothing changed.
Regards.
[root@server:home]$ grep -v '^\s$\|^#\|^;\|^\s#' /opt/cpanel/ea-php72/root/etc/php.d/10-opcache.ini
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=20000
opcache.use_cwd=1
opcache.fast_shutdown=0
opcache.enable_file_override=1
opcache.blacklist_filename=/opt/cpanel/ea-php72/root/etc/php.d/opcache*.blacklist
opcache.file_cache=
opcache.file_cache_only=0
opcache.file_cache_consistency_checks=1
opcache.huge_code_pages=0
opcache.validate_permission=1
Restarted Apache service as well.
[root@server:home]$ service httpd restart
Redirecting to /bin/systemctl restart httpd.service
[root@server:home]$
On 28 Aug 2019, at 10:57, khouloudbelguith notifications@github.com wrote:
@lordchukz https://github.com/lordchukz, you have some missing name in your oPcache configuration
opcache.file_cache
opcache.file_cache_consistency_checks
opcache.file_cache_only
https://user-images.githubusercontent.com/16067358/63841161-32fac880-c97a-11e9-9b6b-6bad68e6ab71.png
You can follow this link: https://www.php.net/manual/en/opcache.configuration.php https://www.php.net/manual/en/opcache.configuration.php
Thanks!—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270?email_source=notifications&email_token=AI2BG74NRXEHBARI3ZK6F3LQGY4ZHA5CNFSM4IQABDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5KMV6Q#issuecomment-525650682, or mute the thread https://github.com/notifications/unsubscribe-auth/AI2BG76XWBLBXLNBPB37BOTQGY4ZHANCNFSM4IQABDWA.
@lordchukz, could you please provide me your PHP info file after these changes.
Thanks!
@khouloudbelguith, please find it attached.
I also got this update from host, might be of help, thanks.
"Rechecked the phpinfo page and I also restarted the Apache PHP-FPM service too. Unfortunately, it does not seem to show those few things up in PHP Version 7.2.21
phpinfo page despite being enabled in the .ini file.
Maybe it is different for the PHP versions they are using for their installations?"
Regards.
@lordchukz, there is no attached file.
You need to connect & upload the file here.
Thanks!
oppsss, my bad.
@lordchukz, I tried to create an environment with PHP7.2.13.
At first, the opcache is not installed.
I tried to install it using this link: https://duntuk.com/enable-zend-opcache-php-55-or-install-zendopcache-php-53-or-php-54
Now, it is well installed & enabled on my server.
I tried to enable the debug mode & it is OK => No exception displayed
https://drive.google.com/file/d/1q2AC4Xs-QNX_FOVXdiTsALSjcR4D2EQ_/view
Thanks!
Hi,
Host gave this feedback.
And sincerely, the more tweaks I give to site, the worse it gets as in performance. (Guess more errors are developing)
Are you a developer? If yes, can you work on site to resolve this for me?
Thanks.
"Upon reviewing that page (https://duntuk.com/enable-zend-opcache-php-55-or-install-zendopcache-php-53-or-php-54 https://duntuk.com/enable-zend-opcache-php-55-or-install-zendopcache-php-53-or-php-54) and his video (https://drive.google.com/file/d/1q2AC4Xs-QNX_FOVXdiTsALSjcR4D2EQ_/view https://drive.google.com/file/d/1q2AC4Xs-QNX_FOVXdiTsALSjcR4D2EQ_/view) and screenshot (https://user-images.githubusercontent.com/16067358/63868637-c1893d00-c9ae-11e9-9b55-f52818532eb7.png https://user-images.githubusercontent.com/16067358/63868637-c1893d00-c9ae-11e9-9b55-f52818532eb7.png) were not sure what exactly he did from the page.
There are a bunch of different things on that page. Please note: This page is for a completely different version of PHP5 and the libraries it links to are from 2014.
Your current setup is using the latest supported opcache by cPanel.
The linked packages provided are for zendopcache-7.0.5 and clearly state in their documentation are for php5.x
http://pecl.php.net/package/ZendOpcache http://pecl.php.net/package/ZendOpcache
Readme:
"This version of Zend OPcache is compatible with PHP 5.2., 5.3., 5.4.* branch.
For PHP 5.5+, please use the bundled Zend Opcache. "
This would also be a nonstandard configuration using a php5.x version of opcache and not supported by us and most likely would cause issues and break PHP.
As you have root access if you wish to make any nonstandard changes this is possible by you or your developer, but any issues related to nonstandard configurations will be out of the scope of our managed services.
Would recommend reaching out to the person who has it working and get more detailed information about their environment and setup and if they're using cPanel all of the Apache and PHP settings they have configured.
We will be happy to make any supported changes requested. So if the other user is using standard cPanel with possibly just different Apache and PHP handler settings then yours we would be happy to set those for you to try. The last-mentioned request would be an example of an unsupported change and would be best performed by a developer with advanced knowledge of that kind of custom configuration.”
On 28 Aug 2019, at 17:17, khouloudbelguith notifications@github.com wrote:
@lordchukz https://github.com/lordchukz, I tried to create an environment with PHP7.2.13.
At first, the opcache is not installed.
I tried to install it using this link: https://duntuk.com/enable-zend-opcache-php-55-or-install-zendopcache-php-53-or-php-54 https://duntuk.com/enable-zend-opcache-php-55-or-install-zendopcache-php-53-or-php-54
Now, it is well installed & enabled on my server.https://user-images.githubusercontent.com/16067358/63868637-c1893d00-c9ae-11e9-9b55-f52818532eb7.png
I tried to enable the debug mode & it is OK => No exception displayed
https://drive.google.com/file/d/1q2AC4Xs-QNX_FOVXdiTsALSjcR4D2EQ_/view https://drive.google.com/file/d/1q2AC4Xs-QNX_FOVXdiTsALSjcR4D2EQ_/view
Thanks!—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270?email_source=notifications&email_token=AI2BG73OV52KBSD2SFIRET3QG2JG7A5CNFSM4IQABDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5LPHUA#issuecomment-525792208, or mute the thread https://github.com/notifications/unsubscribe-auth/AI2BG7YAFHNTUO53DYYUA6DQG2JG7ANCNFSM4IQABDWA.
@lordchukz, thanks for your feedback.
We must first try to reproduce your issue.
In my case with PS1.7.6 a PHP7.0/PHP7.2 => I did not manage to reproduce the issue.
@sarahdib could you please try to reproduce the issue?
Thanks!
I’m thinking it has to do with server configuration..
Since host made some modifications a little before these errors started occurring.. Evaluating making a quick change.
Thanks so much for your assistance, will update with outcomes.
Regards.
On 29 Aug 2019, at 11:30, khouloudbelguith notifications@github.com wrote:
@lordchukz https://github.com/lordchukz, thanks for your feedback.
We must first try to reproduce your issue.
In my case with PS1.7.6 a PHP7.0/PHP7.2 => I did not manage to reproduce the issue.
@sarahdib https://github.com/sarahdib could you please try to reproduce the issue?Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270?email_source=notifications&email_token=AI2BG74B7QALPXO7NOOPEPLQG6JKHA5CNFSM4IQABDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5N3WNY#issuecomment-526105399, or mute the thread https://github.com/notifications/unsubscribe-auth/AI2BG76LHNALFACHA7XKZS3QG6JKHANCNFSM4IQABDWA.
Hello @lordchukz
I try to reproduce but like @khouloudbelguith it's OK for me.
Maybe you can try to see with your hosting provider the change they made and revert it to check if it's OK
Thank you
Best regards
Thanks, @sarahdib!
@lordchukz, despite our several trials, we could not reproduce your issue with the provided information.
It seems that your issue is not a PrestaShop's core bug but most likely a server configuration or customization problem.
Thanks!
Made same request more times but to no avail.. fast switch is best solution.. Will update soon.. Regards.
On 29 Aug 2019, at 11:49, Sarah Dib notifications@github.com wrote:
Hello @lordchukz https://github.com/lordchukz
I try to reproduce but like @khouloudbelguith https://github.com/khouloudbelguith it's OK for me.Maybe you can try to see with your hosting provider the change they made and revert it to check if it's OK
Thank you
Best regards—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270?email_source=notifications&email_token=AI2BG7ZDBBMOMY2DTQ7DV43QG6LRNA5CNFSM4IQABDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5N5MKI#issuecomment-526112297, or mute the thread https://github.com/notifications/unsubscribe-auth/AI2BG7YKG25STKEGKLQUDZLQG6LRNANCNFSM4IQABDWA.
Thanks a lot @khouloudbelguith and @sarahdib sarahdib for your assistance and intervention.
Just want to inform you that problem has been solved. Error due to server configuration. Changed host, and reinstalled all modules, all is working fine now. Regards.
@lordchukz, Great!
Thanks for your feedback.
Thanks a lot @khouloudbelguith and @sarahdib sarahdib for your assistance and intervention.
Just want to inform you that problem has been solved. Error due to server configuration. Changed host, and reinstalled all modules, all is working fine now. Regards.
Can you tell me the problem of the server configuration? cause the same problem here, it does not work
Please see info.php attached.
They also deactivated all third party modules, and tested each on single activation.
Had to uninstall 2 modules and reinstalled them again to gain complete functionality.
The "Activate the Apache module 'mod_auth_basic' to allow authentication of the PrestaShop webservice. #15283" problem is still there, but the technical analyst had a workaround to be able to use web service.
Hope these info are helpful.
Regards.
Please see info.php attached.
They also deactivated all third party modules, and tested each on single activation.
Had to uninstall 2 modules and reinstalled them again to gain complete functionality.
The "Activate the Apache module 'mod_auth_basic' to allow authentication of the PrestaShop webservice. #15283" problem is still there, but the technical analyst had a workaround to be able to use web service.
Hope these info are helpful.
Regards.
Thank you, Do you know the technical workaround?
I did a clean installation of my VPS and a clean installation of prestshop and the problem is still there
Sincerely I don't know the workaround.. :-(
I can recommend my new host, their team are incredibly good..
They've helped me solve different issues on my site and optimised properly (Still on it) loads in less than 2.5 mins for now.
Thank you for your quick response! I'm waiting on our hosting company right now. If it is a workaround, then it is a faulty thing of Prestashop, because it is not working with the high standards on this moment on the servers. Tried now 3 different servers on 2 different hosting companies, all with fresh installations.
Presta 1.7.5.x is working fine with webservice
Just let me know, I can always put you in contact with my new host.
It took me about 10 days to solve this.. :-( what a relieve.
Regards.
Update: It turns out that on the versions 1.7.6.0 and 1.7.6.1 the message is a false one! I have checked the api connection and the output for requests. This works fine.
I can confirm that module for testing opcache isn't working. After install i get
Fatal error: Cannot use variable $request twice in /home/trgovinafigura2/public_html/modules/opcache/opcache/routes.php on line 13
I have similar problem, but with redirecting from BO let say orders directly to FO
when i want to detail of order the link is: https://trgovina-figura.si/XXXXXX/index.php?controller=AdminOrders&id_order=10310&vieworder&token=XXXXXXXXX
and somehow redirect occurred and end up sometimes on https://trgovina-figura.si/si/ or https://trgovina-figura.si/#token
Similar problems on all segments of BO. Luckily FO office is working well so orders keep coming in, but managing orders is nightmare. It started on last thursday
Where to change the code in module to start working? @lordchukz can you give me please info
I'm on Resseler package on dedicated server so my it support is granted me 12 GB RAM, 4vCPU so it should be enough for shop
PrestraShop ver: 1.7.5.2
PHP: 7.2
10.1.45-MariaDB-cll-lve
I have commented out section starting with line 13 in modules/opcache/opcache/routes.php. Then module is displayed properly in BO. But this is not solution, coz then is display one error in line 82.
Hi,
First of all, i'm on a dedicated VPS hosting plan with 100gb space, below are the characteristics.
I solved the opache problem (which was a bug) by removing line 32 "throw new CacheException('OPcache is not enabled’)
I allocated 4gb memory also, server has 6gb memory.
I also installed opcache-gui.php in the public_html directory and can reach it by adding /opcache-gui.php at the end of my domain.
Attached is a file containing the script. remember to save it with .php format and not .txt
One important thing, get your host to install opache for you in your server, they know how to go about it. Get a dedicated server, it’s worth it’s money when you have a good host, I use A2hosting after trying several.
Let me know if you have further questions in regards.
Cheers and best of luck.
Item Detail
Hosting Package default
Server Name server
cPanel Version 86.0 (build 22)
Apache Version 2.4.43
PHP Version 7.2.31
MySQL Version 10.2.32-MariaDB
Architecture x86_64
Operating System linux
Shared IP Address 185.62.136.9
Path to Sendmail /usr/sbin/sendmail
Path to Perl /usr/bin/perl
Perl Version 5.16.3
Kernel Version 2.6.32-042stab141.3
LordsWorld
+39 340 967 1873
www.lordsworld.eu
www.lordspiscine.com
www.lordsutensili.com
https://www.amazon.it/LordsWorld
On 30 Jun 2020, at 19:29, malcek notifications@github.com wrote:
I can confirm that module for testing opcache isn't working. After install i get
Fatal error: Cannot use variable $request twice in /home/trgovinafigura2/public_html/modules/opcache/opcache/routes.php on line 13I have similar problem, but with redirecting from BO let say orders directly to FO
when i want to detail of order the link is: https://trgovina-figura.si/XXXXXX/index.php?controller=AdminOrders&id_order=10310&vieworder&token=XXXXXXXXX https://trgovina-figura.si/XXXXXX/index.php?controller=AdminOrders&id_order=10310&vieworder&token=XXXXXXXXX
and somehow redirect occurred and end up sometimes on https://trgovina-figura.si/si/ https://trgovina-figura.si/si/ or https://trgovina-figura.si/#token https://trgovina-figura.si/#token
Similar problems on all segments of BO. Luckily FO office is working well so orders keep coming in, but managing orders is nightmare. It started on last thursday
Where to change the code in module to start working? @lordchukz https://github.com/lordchukz can you give me please infoI'm on Resseler package on dedicated server so my it support is granted me 12 GB RAM, 4vCPU so it should be enough for shop
PrestraShop ver: 1.7.5.2
PHP: 7.2
10.1.45-MariaDB-cll-lve—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/PrestaShop/PrestaShop/issues/15270#issuecomment-651936808, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI2BG74HDRFGIY3RPEXLJLLRZIOIHANCNFSM4IQABDWA.
namespace OpcacheGui;
/**
*
/*
$options = [
'allow_filelist' => true, // show/hide the files tab
'allow_invalidate' => true, // give a link to invalidate files
'allow_reset' => true, // give option to reset the whole cache
'allow_realtime' => true, // give option to enable/disable real-time updates
'refresh_time' => 5, // how often the data will refresh, in seconds
'size_precision' => 2, // Digits after decimal point
'size_space' => false, // have '1MB' or '1 MB' when showing sizes
'charts' => true, // show gauge chart or just big numbers
'debounce_rate' => 250, // milliseconds after key press to send keyup event when filtering
'cookie_name' => 'opcachegui', // name of cookie
'cookie_ttl' => 365, // days to store cookie
'highlight' => [ // highlight charts/big numbers
'memory' => true,
'hits' => true,
'keys' => true
]
];
/*
if (!extension_loaded('Zend OPcache')) {
die('The Zend OPcache extension does not appear to be installed');
}
$ocEnabled = ini_get('opcache.enable');
if (empty($ocEnabled)) {
die('The Zend OPcache extension is installed but not active');
}
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
class OpCacheService
{
protected $data;
protected $options;
protected $defaults = [
'allow_filelist' => true,
'allow_invalidate' => true,
'allow_reset' => true,
'allow_realtime' => true,
'refresh_time' => 5,
'size_precision' => 2,
'size_space' => false,
'charts' => true,
'debounce_rate' => 250,
'cookie_name' => 'opcachegui',
'cookie_ttl' => 365
];
private function __construct($options = [])
{
$this->options = array_merge($this->defaults, $options);
$this->data = $this->compileState();
}
public static function init($options = [])
{
$self = new self($options);
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
) {
if (isset($_GET['reset']) && $self->getOption('allow_reset')) {
echo '{ "success": "' . ($self->resetCache() ? 'yes' : 'no') . '" }';
} else if (isset($_GET['invalidate']) && $self->getOption('allow_invalidate')) {
echo '{ "success": "' . ($self->resetCache($_GET['invalidate']) ? 'yes' : 'no') . '" }';
} else {
echo json_encode($self->getData((empty($_GET['section']) ? null : $_GET['section'])));
}
exit;
} else if (isset($_GET['reset']) && $self->getOption('allow_reset')) {
$self->resetCache();
header('Location: ?');
exit;
} else if (isset($_GET['invalidate']) && $self->getOption('allow_invalidate')) {
$self->resetCache($_GET['invalidate']);
header('Location: ?');
exit;
}
return $self;
}
public function getOption($name = null)
{
if ($name === null) {
return $this->options;
}
return (isset($this->options[$name])
? $this->options[$name]
: null
);
}
public function getData($section = null, $property = null)
{
if ($section === null) {
return $this->data;
}
$section = strtolower($section);
if (isset($this->data[$section])) {
if ($property === null || !isset($this->data[$section][$property])) {
return $this->data[$section];
}
return $this->data[$section][$property];
}
return null;
}
public function canInvalidate()
{
return ($this->getOption('allow_invalidate') && function_exists('opcache_invalidate'));
}
public function resetCache($file = null)
{
$success = false;
if ($file === null) {
$success = opcache_reset();
} else if (function_exists('opcache_invalidate')) {
$success = opcache_invalidate(urldecode($file), true);
}
if ($success) {
$this->compileState();
}
return $success;
}
protected function size($size)
{
$i = 0;
$val = array('b', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
while (($size / 1024) > 1) {
$size /= 1024;
++$i;
}
return sprintf('%.'.$this->getOption('size_precision').'f%s%s',
$size, ($this->getOption('size_space') ? ' ' : ''), $val[$i]
);
}
protected function compileState()
{
$status = opcache_get_status();
$config = opcache_get_configuration();
$missingConfig = array_diff_key(ini_get_all('zend opcache', false), $config['directives']);
if (!empty($missingConfig)) {
$config['directives'] = array_merge($config['directives'], $missingConfig);
}
$files = [];
if (!empty($status['scripts']) && $this->getOption('allow_filelist')) {
uasort($status['scripts'], function($a, $b) {
return $a['hits'] < $b['hits'];
});
foreach ($status['scripts'] as &$file) {
$file['full_path'] = str_replace('\\', '/', $file['full_path']);
$file['readable'] = [
'hits' => number_format($file['hits']),
'memory_consumption' => $this->size($file['memory_consumption'])
];
}
$files = array_values($status['scripts']);
}
if ($config['directives']['opcache.file_cache_only']) {
$overview = false;
} else {
$overview = array_merge(
$status['memory_usage'], $status['opcache_statistics'], [
'used_memory_percentage' => round(100 * (
($status['memory_usage']['used_memory'] + $status['memory_usage']['wasted_memory'])
/ $config['directives']['opcache.memory_consumption'])),
'hit_rate_percentage' => round($status['opcache_statistics']['opcache_hit_rate']),
'used_key_percentage' => round(100 * (
$status['opcache_statistics']['num_cached_keys']
/ $status['opcache_statistics']['max_cached_keys'])),
'wasted_percentage' => round($status['memory_usage']['current_wasted_percentage'], 2),
'readable' => [
'total_memory' => $this->size($config['directives']['opcache.memory_consumption']),
'used_memory' => $this->size($status['memory_usage']['used_memory']),
'free_memory' => $this->size($status['memory_usage']['free_memory']),
'wasted_memory' => $this->size($status['memory_usage']['wasted_memory']),
'num_cached_scripts' => number_format($status['opcache_statistics']['num_cached_scripts']),
'hits' => number_format($status['opcache_statistics']['hits']),
'misses' => number_format($status['opcache_statistics']['misses']),
'blacklist_miss' => number_format($status['opcache_statistics']['blacklist_misses']),
'num_cached_keys' => number_format($status['opcache_statistics']['num_cached_keys']),
'max_cached_keys' => number_format($status['opcache_statistics']['max_cached_keys']),
'interned' => null,
'start_time' => date('Y-m-d H:i:s', $status['opcache_statistics']['start_time']),
'last_restart_time' => ($status['opcache_statistics']['last_restart_time'] == 0
? 'never'
: date('Y-m-d H:i:s', $status['opcache_statistics']['last_restart_time'])
)
]
]
);
}
if (!empty($status['interned_strings_usage'])) {
$overview['readable']['interned'] = [
'buffer_size' => $this->size($status['interned_strings_usage']['buffer_size']),
'strings_used_memory' => $this->size($status['interned_strings_usage']['used_memory']),
'strings_free_memory' => $this->size($status['interned_strings_usage']['free_memory']),
'number_of_strings' => number_format($status['interned_strings_usage']['number_of_strings'])
];
}
$directives = [];
ksort($config['directives']);
foreach ($config['directives'] as $k => $v) {
if (in_array($k, ['opcache.max_file_size', 'opcache.memory_consumption']) && $v) {
$v = $this->size($v) . " ({$v})";
}
$directives[] = [
'k' => $k,
'v' => $v
];
}
$version = array_merge(
$config['version'],
[
'php' => phpversion(),
'server' => empty($_SERVER['SERVER_SOFTWARE']) ? '' : $_SERVER['SERVER_SOFTWARE'],
'host' => (function_exists('gethostname')
? gethostname()
: (php_uname('n')
?: (empty($_SERVER['SERVER_NAME'])
? $_SERVER['HOST_NAME']
: $_SERVER['SERVER_NAME']
)
)
)
]
);
return [
'version' => $version,
'overview' => $overview,
'files' => $files,
'directives' => $directives,
'blacklist' => $config['blacklist'],
'functions' => get_extension_funcs('Zend OPcache')
];
}
}
$opcache = OpCacheService::init($options);
?>
Most helpful comment
Update: It turns out that on the versions 1.7.6.0 and 1.7.6.1 the message is a false one! I have checked the api connection and the output for requests. This works fine.