Manage your OPcache using CLI through API endpoints.
The OpcacheManagerBundle a simple and fast way to manage your cache using CLI commands and the most useful package for your CI/CD scripts.
OPcache doesn't provide any method to clean your
application cache using a CLI. So, if you want to clean your symfony app cache, you must run
opcache_reset()
function in your web server or your php-fpm process. That is mean that
you need a URL in your app that call the reset function.
Of course, you could use something like php7.4-fpm reload
to refresh OPCache if the user you use
for deployment has permissions.
This is a headache when we use CI/CD tools for the deployment, since we can't reset the cache launching a command.
OpcacheManagerBundle provides some routes to manage your OPCache through symfony commands.
These commands make signed requests to the routes and show results in console. For security reasons,
the request must to be signed (the bundle manage this by itself), so it can't be use directly unless
the APP_SECRET
is known.
composer require saturio/opcache-manager
First of all, active the bundle in your config/bundles.php
file:
// config/bundles.php
<?php
return [
// ...
Saturio\OpcacheManagerBundle\SaturioOpcacheManagerBundle::class => ['all' => true],
];
Add the OpcacheManager routes:
# config/routes/opcache_manager.yml
saturio_opcache:
resource: "@SaturioOpcacheManagerBundle/Resources/config/routing.yaml"
And, finally, configure the OpcacheManager:
# config/packages/saturio_opcache_manager.yaml
saturio_opcache_manager:
server:
default_uri: 'http://127.0.0.1:8000' # Your base URL
👉 Note that you must have a server running your app to use OPCacheManagerBundle.
Use these simple commands:
bin/console saturio:opcache:reset
bin/console saturio:opcache:status
bin/console saturio:opcache:configuration
Clone de repo and run:
composer install
bin/phpunit
Made with ❤️ and without 👮 in Soria.