PHP code example of daoandco / cakephp-cachecleaner

1. Go to this page and download the library: Download daoandco/cakephp-cachecleaner library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daoandco / cakephp-cachecleaner example snippets


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


// config/cachecleaner.php


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

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


// In config/bootstrap.php

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

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

'Dir' => [
	'dirs' => ['persistent'],
],

// 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');
        $parser
            ->description("Task description")
            ->command("demo")
            ;
        return $parser;
    }

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

    public function main() {
        // call with de command : "bin/cake CacheCleaner.clear demo"
        $this->success('OK');
    }

    public function all() {
        // call with de command : "bin/cake CacheCleaner.clear demo -a"
        $this->success('OK');
    }
}


// In config/cachecleaner.php

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

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