visualweber/zfdebug

ZFDebug 是一个为 PHP5 的 Zend 框架提供的插件,它能在每个页面的底部小栏中显示有用的调试信息。

dev-master 2016-08-27 08:37 UTC

This package is not auto-updated.

Last update: 2024-09-13 22:56:04 UTC


README

ZFDebug 是一个为 PHP5 的 Zend 框架提供的插件,它能在每个页面的底部小栏中显示有用的调试信息。

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

目前可用的插件有

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

安装与使用

要安装,请将 'ZFDebug' 文件夹放置在您的库路径中,与 Zend 文件夹相邻。然后向您的引导类(在 ZF1.8+ 中)添加以下方法

在 Bootstrap.php 中

protected function _initZFDebug() {
    if (Zend_Registry::isRegistered('config') && $config = Zend_Registry::get('config')) {
        if ($config ['settings'] ['debug']['enabled'] == false):
            return true;
        else:
            $autoloader = Zend_Loader_Autoloader::getInstance();
            $autoloader->registerNamespace('ZFDebug');
        endif;
    }

    $options = array(
        'plugins' => array(
            'Variables',
            //'ZFDebug_Controller_Plugin_Debug_Plugin_Debug' => array('tab' => 'Debug', 'panel' => ''),
            'ZFDebug_Controller_Plugin_Debug_Plugin_Auth',
            'File' => array('basePath' => PATH_PROJECT),
            'Database',
            'Registry',
            'Memory',
            'Time',
            'Exception'
        ),
        'jquery_path' => '');
    // Setup the cache plugin
    if (Zend_Registry::isRegistered('cache')) {
        $cache = Zend_Registry::get('cache');
        $options ['plugins'] ['Cache'] ['backend'] = $cache->getBackend();
    }

    // Setup the databases
    $resource = $this->getPluginResource('multidb');
    if (Zend_Registry::isRegistered('config')) {
        $config = Zend_Registry::get('config');
        $databases = $config ['resources'] ['multidb'];
        foreach ($databases as $name => $adapter) {
            $db_adapter = $resource->getDb($name);
            $options ['plugins'] ['Database'] ['adapter'] [$name] = $db_adapter;
        }
    }

    // Init the ZF Debug Plugin
    $debug = new ZFDebug_Controller_Plugin_Debug($options);
    $this->bootstrap('frontController');
    $frontController = $this->getResource('frontController');
    $frontController->registerPlugin($debug);
}

在 .ini 中

[development : bootstrap] settings.debug.enabled = 1 ; 启用调试栏

使用 Composer

现在您可以使用 Composer 依赖管理工具安装 ZFDebug。

要使用 Composer 使用 ZFDebug,请将以下内容添加到项目中 composer.json 文件的要求列表中

"require": {
    "visualweber/zfdebug": "0.1"
},

运行安装命令以解析和下载依赖项

php composer.phar install

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