lciolecki / zf-debug
ZFDebug - Zend Framework 的调试栏
该软件包的官方仓库似乎已不存在,因此软件包已被冻结。
dev-master
2014-08-06 12:09 UTC
Requires
- php: >=5.4
- zendframework/zendframework1: 1.*
This package is not auto-updated.
Last update: 2022-12-19 17:21:04 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 文件夹旁边。然后向您的引导类(在 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 迁移的进行,将进一步提供文档。