CacheCleaner plugin for CakePHP, this shell clean the cache of your application
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

CacheCleaner plugin for CakePHP

This plugin is a shell that cleans the cache in your application


  • PHP version 5.4.16 or higher
  • CakePhp 3.0 or higher


You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require daoandco/cakephp-cachecleaner

Loading the Plugin

  // In config/bootstrap.php
  Plugin::load('CacheCleaner', ['bootstrap' => true, 'routes' => false]);

Quick Start

Clear all cache

bin/cake CacheCleaner.clear -a

Clear cake cache

bin/cake CacheCleaner.clear cake



It's the equivalent to orm_cache clear. See more informations

bin/cake CacheCleaner.clear orm


Clear the cache generate by Cake\Cache\Cache

bin/cake CacheCleaner.clear cake


Resets the entire opcode cache, See more informations

bin/cake CacheCleaner.clear opcache


Clear directories in "tmp/cache/"

  • Clear all directories
bin/cake CacheCleaner.clear dir -a
  • Clear one directory
bin/cake CacheCleaner.clear dir dir_name
  • Clear many directories
bin/cake CacheCleaner.clear dir dir_name other_dir_name


Create config file

Create a file in app/config like 'vendor/daoandco/cakephp-cachecleaner/config/config.php'

// config/cachecleaner.php

return [
    'CacheCleaner' => [
        'tasks' => ['CacheCleaner.Dir', 'CacheCleaner.Orm', 'CacheCleaner.Cake', 'CacheCleaner.Opcache'],

        'Dir' => [
            'dirs' => true,

Load configuration

// In config/bootstrap.php

Configure::load('cachecleaner', 'default');


  • tasks : add or remove tasks Exemple : if you do not want Opcache you can write
tasks' => ['CacheCleaner.Dir', 'CacheCleaner.Orm', 'CacheCleaner.Cake'],
  • Dir.dirs : choose the folders to clear Exemple : if you want clear only persistent forler you can write
'Dir' => [
	'dirs' => ['persistent'],

Create a new task for your usage

You can add your own tasks, Your class must implement Task Interface

Create the task

// In Shell/Task

namespace App\Shell\Task;

use Cake\Console\Shell;
use Cake\Console\ConsoleOptionParser;
use CacheCleaner\Shell\Task\TaskInterface;

class DemoTask extends Shell implements TaskInterface {

    public function getOptionParser() {
        $parser = new ConsoleOptionParser('console');
            ->description("Task description")
        return $parser;

    public function help() {
        return 'Task description';

    public function main() {
        // call with de command : "bin/cake CacheCleaner.clear demo"

    public function all() {
        // call with de command : "bin/cake CacheCleaner.clear demo -a"

Load the task

// In config/cachecleaner.php

return [
    'CacheCleaner' => [
        'tasks' => ['CacheCleaner.Dir', 'CacheCleaner.Orm', 'CacheCleaner.Cake', 'CacheCleaner.Opcache', 'Demo'],

        'Dir' => [
            'dirs' => true,