2017 © Pedro Peláez
 

yii-extension yii2-debug

Yii debug toolbar

image

zhuravljov/yii2-debug

Yii debug toolbar

  • Friday, November 10, 2017
  • by Zhuravljov
  • Repository
  • 18 Watchers
  • 137 Stars
  • 122,112 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 25 Forks
  • 6 Open issues
  • 11 Versions
  • 6 % Grown

The README.md

yii2-debug

Debug panel for Yii 1.1 (ported from Yii 2)., (*1)

Latest Stable Version Total Downloads, (*2)

Installation

This extension is available at packagist.org and can be installed via composer by following command:, (*3)

composer require --dev zhuravljov/yii2-debug., (*4)

If you want to install this extension manually just copy sources to /protected/extensions directory., (*5)

To enable toolbar in your application add following lines to config:, (*6)

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:, (*7)

  • 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:, (*8)

'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., (*9)

Example:, (*10)

'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:, (*11)

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:, (*12)

'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., (*13)

Example: Disable core profiling panel, (*14)

'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., (*15)

Miscellaneous

Status Code

If you using PHP < 5.4, debug panel can't detect redirects by himself. You can use following code as workaround:, (*16)

'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., (*17)

The Versions

10/11 2017

dev-master

9999999-dev https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

debug extension yii

10/11 2017

1.5.2

1.5.2.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

debug extension yii

02/05 2017

v1.5.1

1.5.1.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

debug extension yii

29/10 2016

v1.5

1.5.0.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

debug extension yii

13/07 2016

v1.4.2

1.4.2.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

debug extension yii

18/11 2015

v1.4.1

1.4.1.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

debug extension yii

16/01 2015

v1.4

1.4.0.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

debug extension yii

21/07 2014

v1.3

1.3.0.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.1.0

 

by Roman Zhuravlev

debug extension yii

02/06 2014

v1.2

1.2.0.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.1.0

 

by Roman Zhuravlev

debug extension yii

17/10 2013

v1.1

1.1.0.0 https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.1.0

 

by Roman Zhuravlev

debug extension yii

28/09 2013

v1.1rc

1.1.0.0-RC https://github.com/zhuravljov/yii2-debug

Yii debug toolbar

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.1.0

 

by Roman Zhuravlev

debug extension yii