reneaigle/zfdebug

用于 Zend Framework 1 和 Doctrine2 插件的调试工具

dev-master 2013-05-28 17:05 UTC

This package is not auto-updated.

Last update: 2024-09-28 13:30:21 UTC


README

ZFDebug 是一个为 PHP5 的 Zend Framework 提供的插件,它在一个小条上显示每页的调试信息。

时间消耗、内存使用量和数据库查询次数一目了然。此外,还包括包含的文件、可用的视图变量列表以及所有查询的完整 SQL 命令,这些都在独立的面板中显示。

目前可用的插件有:

  • 缓存:关于 Zend_Cache 和 APC 的信息。
  • 数据库:从 Zend_Db 的完整 SQL 查询列表及其时间。
  • 异常:错误和异常的处理。
  • 文件:包含的文件数量和大小,完整列表。
  • HTML:外部样式表和 JavaScript 的数量。通过 W3C 验证链接。用于自定义内存测量。
  • 日志:当前请求的计时信息、动作控制器中的时间消耗和自定义计时器。还包括请求的平均、最小和最大时间。
  • 变量:视图变量、请求信息和 $_COOKIE$_POST$_SESSION 的内容。

安装与使用

要安装,请将 '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);
}

Doctrine2 插件

以下是为使用 Doctrine2 插件提供的示例配置。

protected function _initZFDebug()
{
	if (APPLICATION_ENV == 'development') {
		$autoloader = Zend_Loader_Autoloader::getInstance();
		$autoloader->registerNamespace('ZFDebug');
		$em = $this->bootstrap('doctrine')->getResource('doctrine')->getEntityManager();
		$em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
		
		$options = array(
			'plugins' => array(
				'Variables',
				'ZFDebug_Controller_Plugin_Debug_Plugin_Doctrine2'	=> array(
					'entityManagers' => array($em),
				),
				'File'			=> array('basePath' => APPLICATION_PATH . '/application'),
				//'Cache'		=> array('backend' => $cache->getBackend()),
				'Exception',
				'Html',
				'Memory',
				'Time',
				'Registry',
			)
		);
		
		$debug = new ZFDebug_Controller_Plugin_Debug($options);
		$this->bootstrap('frontController');
		$frontController = $this->getResource('frontController');
		$frontController->registerPlugin($debug);
	}
}

随着 GitHub 迁移的进展,将提供更多文档。