문제

How can I disable yii-debug-toolbar on a specific view especially on partial rendered views?

Is this possible?

p.s. Yii-debug-toolbar does unfortunately not exist as a tag below.

도움이 되었습니까?

해결책

Put this in your layout or view file:

if (class_exists('yii\debug\Module')) {
    $this->off(\yii\web\View::EVENT_END_BODY, [\yii\debug\Module::getInstance(), 'renderToolbar']);
}

This removes the callback that renders the toolbar from the event that runs at the end of the layout, where you have $this->endBody().

다른 팁

Just Remove or comments out the those two lines from /config/web.php

$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';

I found a better way. Put This In Anywhere:

Yii::$app->log->targets['debug'] = null;

And this does not make files in /runtime/debug

public function beforeAction($action) {

    if ( $action->controller->id=='elfinder' && Yii::$app->getModule('debug') )
        Yii::$app->getModule('debug')->instance->allowedIPs = [];
    return parent::beforeAction($action);
}

if you want to remove from front end then this is the way:

  1. Goto frontend/config/main-local.php
  2. Comment out these two lines:

main-local.php

  $config['bootstrap'][] = 'debug';    
  $config['modules']['debug'] = 'yii\debug\Module';

This will remove debug bar from front-end.

Open the file Your-Project-Name\vendor\yiisoft\yii2-debug\src\assets\js\toolbar.js.

Change line toolbarEl.style.display = 'block'; to toolbarEl.style.display = 'none';

To stop collection log data in a single action or all actions in a single controller I did this and it brought down the memory footprint significantly.

public function beforeAction($action)
{
    if (YII_DEBUG && Yii::$app->getModule('debug'))
    {
        foreach (Yii::$app->getModule('debug')->get('log')->targets as $Target)
        {
            $Target->enabled = false;
        }

        // If you are using Yii framework version >= 2.0.14 you may also
        // want to disable the event registered by EventPanel because it
        // could also use a lot of memory.
        \yii\base\Event::off('*', '*');
    }

    return parent::beforeAction($action);
}
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';

Comment out the above lines of code above. this worked for me. This do in frontend and backend to disable that debug tool or module at the footer of the website.

Remove this from config/web.php

$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';

If you don't wan to show the log, you can hide the yii-debug console using jQuery

   $('#ydtb-toolbar').hide();

Call this snippet on your views.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top