zhuravljov/yii2-debug
Composer 安装命令:
composer require zhuravljov/yii2-debug
包简介
Yii debug toolbar
关键字:
README 文档
README
Debug panel for Yii 1.1 (ported from Yii 2).
Installation
This extension is available at packagist.org and can be installed via composer by following command:
composer require --dev zhuravljov/yii2-debug.
If you want to install this extension manually just copy sources to /protected/extensions directory.
To enable toolbar in your application add following lines to config:
return array( 'preload' => array( 'debug', ), 'components' => array( 'debug' => array( 'class' => 'vendor.zhuravljov.yii2-debug.Yii2Debug', // composer installation //'class' => 'ext.yii2-debug.Yii2Debug', // manual installation ), 'db' => array( 'enableProfiling' => true, 'enableParamLogging' => true, ), ), );
Configuration
You can customize debug panel behavior with this options:
enabled- enable/disable debug panel.allowedIPs- list of IPs that are allowed to access debug toolbar. Defaultarray('127.0.0.1', '::1').accessExpression- additional php expression for access evaluation.logPath- directory storing the debugger data files. This can be specified using a path alias. Default/runtime/debug.historySize- maximum number of debug data files to keep. If there are more files generated, the oldest ones will be removed.highlightCode- highlight code. Highlight SQL queries and PHP variables. This parameter can be set for each panel individually.moduleId- module ID for viewing stored debug logs. Defaultdebug.showConfig- show brief application configuration page. Defaultfalse.hiddenConfigOptions- list of unsecure component options to hide (like login, passwords, secret keys). Default is to hideusernameandpasswordofdbcomponent.internalUrls- use nice routes rules in debug module.panels- list of debug panels.
Each attached panel can be configured individually, for example:
'debug' => array( 'class' => 'ext.yii2-debug.Yii2Debug', 'panels' => array( 'db' => array( // Disable code highlighting. 'highlightCode' => false, // Disable substitution of placeholders with values in SQL queries. 'insertParamValues' => false, ), ), ),
Each panel have callback option filterData.
You can define custom function for filtering input data before writing it in to debug log.
It's useful when you need to hide something secret or just delete data from logs.
Be careful with data structure manipulation. It can lead to log parsing errors.
Example:
'debug' => array( 'class' => 'ext.yii2-debug.Yii2Debug', 'panels' => array( 'db' => array( 'filterData' => function($data){ // Your code here return $data; } ), ), ),
Creating own panels
To create own debug panel you can extend class Yii2DebugPanel, for example:
class MyTestPanel extends Yii2DebugPanel { /** * The name of panel printed in debugger */ public function getName() { return 'Name'; } /** * Return summary html with results of execution in current request. * Data is available through $this->data */ public function getSummary() { return ''; } /** * Return detailed html report with results of execution in current request. * Data is available through $this->data */ public function getDetail() { return ''; } /** * Return data required for storing in logs. */ public function save() { return array(); } }
And attach this panel in config:
'panels' => array( 'test' => array( 'class' => 'path.to.panel.MyTestPanel', // ... ), ),
Disable individual panels
To disable an individual panel, either a core or custom panel, set the enabled property in the panel config to false.
Example: Disable core profiling panel
'panels' => array( 'profiling' => array( 'enabled' => false, // ... ), ),
Variables dumping
With static method Yii2Debug::dump() you can dump any data and examine it later in debug log.
Miscellaneous
Status Code
If you using PHP < 5.4, debug panel can't detect redirects by himself. You can use following code as workaround:
'panels' => array( 'request' => array( 'filterData' => function($data){ if (empty($data['statusCode'])) { if (isset($data['responseHeaders']['Location'])) { $data['statusCode'] = 302; } else { $data['statusCode'] = 200; } } return $data; }, ), ),
Such code just set 302 code if Location header is present.
Codes like 4xx and 5xx can be detected in debug panel by himself.
In PHP 5.4 and higher debug panel uses native php function http_response_code() for detecting http response code,
and there is no need to use this workaround.
zhuravljov/yii2-debug 适用场景与选型建议
zhuravljov/yii2-debug 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 511.87k 次下载、GitHub Stars 达 144, 最近一次更新时间为 2013 年 08 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「debug」 「extension」 「yii」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zhuravljov/yii2-debug 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zhuravljov/yii2-debug 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zhuravljov/yii2-debug 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Debug your SimpleBus EventBus and CommandBus
nice output for debug functions for PHP 5.3
A custom URL rule class for Yii 2 which allows to create translated URL rules
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 511.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 146
- 点击次数: 26
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2013-08-20