ZFDebug - Zend Framework 的调试工具
Friday, March 19, 2010 1:38:24 AM
现在有一个叫 ZFDebug 的东西,实现了调试过程的标准化,个人感觉这东西挺不赖,因此推荐一下。
安装过程很简单:
1. ZFDebug 文件夹拷贝到和 Zend 同级目录下面。
2. 在 Bootstrap.php 中追加代码:
protected function _initZFDebug()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
$options = array(
'plugins' => array('Variables',
'File' => array('base_path' => '/path/to/project'),
'Memory',
'Time',
'Registry',
'Exception')
);
# Instantiate the database adapter and setup the plugin.
# Alternatively just add the plugin like above and rely on the autodiscovery feature.
if ($this->hasPluginResource('db')) {
$this->bootstrap('db');
$db = $this->getPluginResource('db')->getDbAdapter();
$options['plugins']['Database']['adapter'] = $db;
}
# Setup the cache plugin
if ($this->hasPluginResource('cache')) {
$this->bootstrap('cache');
$cache = $this-getPluginResource('cache')->getDbAdapter();
$options['plugins']['Cache']['backend'] = $cache->getBackend();
}
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
注意以上代码仅适用于 ZF 1.8 以上版本。







