Use CacheTool to view stats for and manage PHP's APC or Zend Opcache opcode cache.
Using CacheTool you can clear the PHP opcache without reloading PHP-FPM.
In this example, CacheTool is to be installed alongside a demonstration PHP-FPM Docker container.
$ docker run \
--detach \
--name php56 \
--publish 8888:80 \
jdeathe/centos-ssh-apache-php:2.1.1
Check it works.
$ curl -I http://localhost:8888/
Request again, or request another URL, to generate some cache usage.
$ curl -I http://localhost:8888/_phpinfo.php
In the demonstration app PHP files are restricted to /var/www/app
by the open_basedir
directive so the CacheTool should be installed into the /var/www/app/bin
directory with appropriate permissions.
$ docker exec -i php56 curl -s \
-o /var/www/app/bin/cachetool.phar \
http://gordalina.github.io/cachetool/downloads/cachetool.phar
$ docker exec -i php56 chmod 750 /var/www/app/bin/cachetool.phar
$ docker exec -i php56 chown app:app /var/www/app/bin/cachetool.phar
$ docker exec -i php56 \
php /var/www/app/bin/cachetool.phar \
--tmp-dir=/var/www/app/var/tmp \
--fcgi=/var/run/php-fpm/app-www.sock \
opcache:status
opcache:configuration
Get configuration information about the cacheopcache:invalidate:scripts
Remove scripts from the opcode cacheopcache:reset
Resets the contents of the opcode cacheopcache:status
Show summary information about the opcode cacheopcache:status:scripts
Show scripts in the opcode cache
$ docker exec -i php56 \
php /var/www/app/bin/cachetool.phar help