All Projects → zhuravljov → Yii2 Debug

zhuravljov / Yii2 Debug

Debug panel for Yii 1.1 (ported from Yii 2)

Labels

Projects that are alternatives of or similar to Yii2 Debug

Yii2 Chartjs Widget
ChartJs Widget For Yii2
Stars: ✭ 95 (-32.14%)
Mutual labels:  yii
Yii2 Swiftmailer
Yii 2 swiftmailer extension.
Stars: ✭ 109 (-22.14%)
Mutual labels:  yii
Cms
SkeekS CMS (Yii2)
Stars: ✭ 128 (-8.57%)
Mutual labels:  yii
Yii2 Openapi
REST API application generator for Yii2, openapi 3.0 YAML -> Yii2
Stars: ✭ 99 (-29.29%)
Mutual labels:  yii
Ar Position
ActiveRecord behavior, which provides ability for custom records order setup
Stars: ✭ 107 (-23.57%)
Mutual labels:  yii
File Storage
File storage abstraction for Yii2
Stars: ✭ 116 (-17.14%)
Mutual labels:  yii
Yii2 Aws S3
An Amazon S3 component for Yii2
Stars: ✭ 86 (-38.57%)
Mutual labels:  yii
Yii2 Plus
Yii2 Plus 集成了用户管理模块和权限管理模块,前端页面采用H+ UI框架,集成Yii2 admin。
Stars: ✭ 132 (-5.71%)
Mutual labels:  yii
Rageframe2
一个基于Yii2高级框架的快速开发应用引擎
Stars: ✭ 1,553 (+1009.29%)
Mutual labels:  yii
Yii2 Jui
Yii 2 JQuery UI extension.
Stars: ✭ 120 (-14.29%)
Mutual labels:  yii
Admin
Admin pack (actions, widgets, etc) for Yii2
Stars: ✭ 100 (-28.57%)
Mutual labels:  yii
Yii2 Google Maps Library
Google Maps API library for Yii2
Stars: ✭ 104 (-25.71%)
Mutual labels:  yii
Yii2 2.0.3 Annotated
带有详细注释的 yii2 2.0.3 代码。喜欢的话请点star,欢迎大家一起来补充
Stars: ✭ 117 (-16.43%)
Mutual labels:  yii
Yeeki
Yii 1.1-based wiki
Stars: ✭ 96 (-31.43%)
Mutual labels:  yii
Yii2 Shell
Interactive shell
Stars: ✭ 129 (-7.86%)
Mutual labels:  yii
Yii2 Practice Book
Yii 2.0 最佳实践
Stars: ✭ 91 (-35%)
Mutual labels:  yii
Vue Zhidian
YII2+VUE2开发的SCRM后台项目
Stars: ✭ 115 (-17.86%)
Mutual labels:  yii
Yii2 Swagger
yii2 with swagger-php
Stars: ✭ 138 (-1.43%)
Mutual labels:  yii
Yii2 Twig
Yii 2 Twig extension.
Stars: ✭ 130 (-7.14%)
Mutual labels:  yii
Yii2 App Advanced
Yii 2.0 Advanced Application Template
Stars: ✭ 1,569 (+1020.71%)
Mutual labels:  yii

yii2-debug

Debug panel for Yii 1.1 (ported from Yii 2).

Latest Stable Version Total Downloads

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. Default array('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. Default debug.
  • showConfig - show brief application configuration page. Default false.
  • hiddenConfigOptions - list of unsecure component options to hide (like login, passwords, secret keys). Default is to hide username and password of db component.
  • 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].