sobolandrej / zf-debug
ZFDebug - 为Zend Framework提供的调试工具栏
1.6.7
2017-12-14 15:02 UTC
Requires
- php: >=5.4
- zendframework/zendframework1: 1.*
This package is not auto-updated.
Last update: 2024-09-29 02:46:08 UTC
README
ZFDebug 是一个PHP5的Zend Framework插件,它提供一个小的工具栏,显示在每页底部,提供有用的调试信息。
时间消耗、内存使用和数据库查询次数一目了然。此外,还包括文件列表、可用视图变量以及所有查询的完整SQL命令,分别显示在独立的面板中。
目前可用的插件有:
- 缓存:关于Zend_Cache和APC的信息。
- 数据库:显示Zend_Db的所有SQL查询的完整列表及其时间。
- 异常:错误和异常的处理。
- 文件:包含的文件数量和大小,以及完整列表。
- HTML:外部样式的数量和JavaScript的数量。提供W3C验证链接,用于自定义内存测量。
- 日志:当前请求的计时信息、操作控制器中花费的时间以及自定义计时器。还包括请求的平均、最小和最大时间。
- 变量:视图变量、请求信息和
$_COOKIE
、$_POST
和$_SESSION
的内容。
安装
{
"minimum-stability": "dev",
"require": {
"lciolecki/zf-debug" : "dev-master"
}
}
使用方法
要安装,请将“ZFDebug”文件夹放置在您的库路径中,与Zend文件夹相邻。然后,将以下方法添加到您的bootstrap类中(在ZF1.8+中)
protected function _initZFDebug()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
$options = array(
'plugins' => array('Variables',
'Database' => array('adapter' => $db),
'File' => array('basePath' => '/path/to/project'),
'Cache' => array('backend' => $cache->getBackend()),
'Exception')
);
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
Doctrine 1插件
以下是使用Doctrine插件示例配置
protected function _initZFDebug()
{
if (APPLICATION_ENV === 'development') {
$options = array(
'plugins' => array(
'Variables',
'File',
'Memory',
'Time',
new ZFDebug_Controller_Plugin_Debug_Plugin_Doctrine(),
'Exception'
)
);
$ZFDebug = new ZFDebug_Controller_Plugin_Debug($options);
$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin($ZFDebug);
return $ZFDebug;
}
}
Doctrine2插件
以下是使用Doctrine2插件示例配置
protected function _initDebug()
{
if (APPLICATION_ENV === 'development') {
$em = Zend_Registry::get('em');
$em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
$cacheResource = $this->getPluginResource('cachemanager');
$cacheManager = $cacheResource->getCacheManager();
$cache = $cacheManager->getCache('data');
$cacheBackend = $cache->getBackend();
$options = array(
'plugins' => array(
'Variables',
'ZFDebug_Controller_Plugin_Debug_Plugin_Doctrine2' => array(
'entityManagers' => array(Zend_Registry::get('em')),
),
'Cache' => array('backend' => $cacheBackend),
'File' => array('basePath' => APPLICATION_PATH . '/application'),
'Exception',
'Html',
'Memory',
'Time',
)
);
Zend_Controller_Front::getInstance()->registerPlugin(new ZFDebug_Controller_Plugin_Debug($options));
}
}
随着GitHub迁移的进展,将提供更多文档。