yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Debug db panel for rest #7471

Closed eaglemoor closed 9 years ago

eaglemoor commented 9 years ago

Hi. I try use yii2-debug db panel for show request online in rest

web.php

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['components']['response']['on beforeSend'] = function ($event) {
        /** @var \yii\debug\Module $debug */
        $debug = Yii::$app->getModule('debug');

        var_dump($debug->panels['db']->models);
    }
}

But this work only on Yii Debug page. How i can display all query after action? It's need for profiling rest online (without log file)

samdark commented 9 years ago

It's not correct to do so. It will affect response body so client won't be able to handle it.

Debug should remember previous requests so

  1. Do API request.
  2. Open web page and get to debug toolbar.
  3. Select API request from previous requests dropdown.