Question

http://docs.phalconphp.com/en/0.6.0/reference/di.html

in public/index.php, codeing :

$di->set('viewCache', function(){

    //Cache data for one day by default
    $frontCache = new Phalcon\Cache\Frontend\Output(array(
            "lifetime" => 86400
    ));

    //Memcached connection settings
    $cache = new Phalcon\Cache\Backend\File($frontCache, array(
            "cacheDir" => "../apps/caches/"
    ));

    return $cache;
});

that,in controller,i can use this->view->cache(), why not viewCache not in service name conventions?

Was it helpful?

Solution

The service viewCache can be accessed like this:

// In controller
$this->view->cache();

or

// In controller 
$this->di->get('viewCache');

or

// In a module or other file
$di = \Phalcon\DI::getDefault();
$di->get('viewCache');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top