Enable Yii2 Debugger Toolbar

 ·  · 

Tutorial about how to enable debugger toolbar in your Yii2 application.

 

1 Installation

Add yii2-debug to your composer.json file:

"require": {
    "yiisoft/yii2-debug": "*"
},

Then update your Composer dependencies.

$ composer update

Alternatively, you can let Composer do these automatically.

$ composer require --prefer-dist yiisoft/yii2-debug

 

2 Usage

2.1 Basic Template

For Yii2 basic template, edit config/web.php in your project.

// ...
if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        'allowedIPs' => ['*'],
    ];

    // ...
}

2.2 Advanced Template

If your project uses Yii2 advanced project template, for example, to enable debugger toolbar in your frontend application, please edit your frontend/config/main-local.php file.

// ...
if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        'allowedIPs' => ['*'],
    ];

    // ...
}

Then you will see a debugger toolbar showing at the bottom of every page of your frontend application.