Clean application cache with single command
The best way to install modette/cache-cleaner is using Composer:
$ composer require modette/cache-cleaner
Register in your config.neon
:
extensions:
cacheCleaner: Modette\CacheCleaner\DI\CleanerExtension
cacheCleaner:
cleaners: # cleaners list
- Modette\CacheCleaner\Cleaners\LocalFilesystemCleaner([%tempDir%])
- Modette\CacheCleaner\Cleaners\NetteCachingStorageCleaner()
- cleans both user and system APC cache
Modette\CacheCleaner\Cleaners\ApcCleaner()
Modette\CacheCleaner\Cleaners\ApcuCleaner()
- recursively purge directories
- second parameter accepts directories and files which should be ignored
Modette\CacheCleaner\Cleaners\LocalFilesystemCleaner([%tempDir%], [%tempDir%/ignored/])
- cleans all Memcache storages in DI container
Modette\CacheCleaner\Cleaners\MemcacheCleaner()
- cleans all Memcached storages in DI container
Modette\CacheCleaner\Cleaners\MemcachedCleaner()
- cleans all Nette\Caching\IStorage instances in DI container
Modette\CacheCleaner\Cleaners\NetteCachingStorageCleaner()
- cleans opcode
Modette\CacheCleaner\Cleaners\OpcodeCleaner()
Run command in Symfony console
$ cache:clean
Add -v
parameter to display more detailed informations
<?php
// get Modette\CacheCleaner\CacheCleaner from DI container
$cleaner->clean(new \Symfony\Component\Console\Output\NullOutput());
Implement ICleaner
and register it in cleaners list
<?php
class YourCleaner implements \Modette\CacheCleaner\Cleaners\ICleaner
{
public function clean(\Symfony\Component\Console\Output\OutputInterface $output): void
{
// clean cache
// inform about it in console
}
}
Repository of package: https://github.com/modette/cache-cleaner.