0

我正在使用 Zend Framework 开发一个网站,我希望使用 ZFDebug。我按照此处
描述的安装说明进行操作,但我没有在引导程序中初始化 Zend_Cache(在配置文件部分定义缓存管理器设置)。 因此,我的 ZFDebug 引导部分类似于以下内容:

if ($this->hasPluginResource("cachemanager")) {
    $this->bootstrap("cachemanager");
    $cache = $this->getPluginResource("cachemanager")->getCacheManager()->getCache("default");
    $options["plugins"]["Cache"] = array("backend" => $cache->getBackend());
}
$debug = new ZFDebug_Controller_Plugin_Debug($options);

使用此代码 ZFDebug 在菜单中显示“缓存”项,但不可单击。我应该怎么做才能让 ZFDebug 显示缓存信息?我使用 Xcache 作为 Zend_Cache 后端。

4

1 回答 1

0

我今天早上才开始玩 ZFDebug,但我的 Boostrap.php init 是缓存并首先注册它。在 _initZFDebug 我调用注册表来获取缓存。

protected function _initCache()
{
    $frontendOptions = array(
        'lifetime' => 3600*24*5, // cache lifetime of 5 days
        'automatic_serialization' => true,
        'logging' => false,
        'caching' => true
    );

    $backendOptions = array(
        'cache_dir' => './../data/cache/', // Directory where to put the cache files
        'hashed_directory_level' => 2
    );

    $flickrFrontendOptions = array(
        'lifetime' => 3600*24*5, // cache lifetime of 5 days
        'automatic_serialization' => true,
        'logging' => false,
        'caching' => true
    );

    $flickrBackendOptions = array(
        'cache_dir' => './../data/flickr/', // Directory where to put the cache files
        'hashed_directory_level' => 2
    );

    // getting a Zend_Cache_Core object
    $cache = Zend_Cache::factory(
        'Core',
        'File',
        $frontendOptions,
        $backendOptions);
    Zend_Registry::set('cache', $cache);

    $flickrcache = Zend_Cache::factory(
        'Core',
        'File',
        $flickrFrontendOptions,
        $flickrBackendOptions);
    Zend_Registry::set('flickrcache', $flickrcache);
}

protected function _initZFDebug()
{
    if ($this->hasOption('zfdebug'))
    {
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('ZFDebug');

        $options = array(
            'plugins' => array('Variables', 
                               'Database' => array('adapter' => $db), 
                               'File' => array('basePath' => $this->hasOption('zfdebug.basePath')),
                               'Cache' => array('backend' => Zend_Registry::get('cache')->getBackend()), 
                               'Exception')
        );
        $debug = new ZFDebug_Controller_Plugin_Debug($options);

        $this->bootstrap('frontController');
        $frontController = $this->getResource('frontController');
        $frontController->registerPlugin($debug);
    }
}
于 2012-01-27T12:02:50.140 回答