jdolieslager/celeritas

0.2.4 2013-08-02 12:34 UTC

README

Installation

1. Add the following configuration to your config/application.config.php

array(
  'celeritas_options' => array(
        'enabled'           => true,
        'cache_file'        => __DIR__ . '/../data/cache/classcache/' .
                               md5(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) .
                               '.php',
        // Those namespaces / full classnames will not be cached
        'ignore_namespaces' => array(
            'Celeritas',
            'Composer',
            'composer',
        ),
        // Those request extensions will be ignored. (Example: /img/bg.png or /css/app.css)
        'ignore_extensions' => array(
            'css',
            'js',
            'gif',
            'png',
            'jpg',
            'ico',
        ),
    ),
);

2. Add the following to your index.php before including the autoloader

$applicationConfig = require 'config/application.config.php';

if (
    $applicationConfig['celeritas_options']['enabled'] &&
    is_file($applicationConfig['celeritas_options']['cache_file'])
) {
    require_once $applicationConfig['celeritas_options']['cache_file'];
}

// Autoloading and stuff

Zend\Mvc\Application::init($applicationConfig)->run();

3. Make sure that the cache_file directory is writable.

Note: For development it is better to disable the caching mechanisme

Additional features

  1. Prevent class caching
/** @var \Zend\Mvc\MvcEvent $mvcEvent */
$eventManager = $mvcEvent->getTarget()->getEventManager();

// No Cache
$eventManager->trigger('celeritas.no_cache', $this, array());