jdolieslager/celeritas

0.2.4 2013-08-02 12:34 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:52:29 UTC


README

#Celeritas

安装

1. 在 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. 在 index.php 中包含自动加载器之前添加以下内容

$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. 确保缓存文件目录可写。

注意:对于开发,最好是禁用缓存机制。

其他功能

  1. 防止类缓存
/** @var \Zend\Mvc\MvcEvent $mvcEvent */
$eventManager = $mvcEvent->getTarget()->getEventManager();

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