How can I disable yii-debug-toolbar on a specific view?

后端 未结 8 1407
你的背包
你的背包 2021-02-02 12:58

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

Is this possible?

p.s. Yii-debug-toolbar

相关标签:
8条回答
  • 2021-02-02 13:32

    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().

    0 讨论(0)
  • 2021-02-02 13:35
    public function beforeAction($action) {
    
        if ( $action->controller->id=='elfinder' && Yii::$app->getModule('debug') )
            Yii::$app->getModule('debug')->instance->allowedIPs = [];
        return parent::beforeAction($action);
    }
    
    0 讨论(0)
  • 2021-02-02 13:36
    $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.

    0 讨论(0)
  • 2021-02-02 13:37

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

    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';
    
    0 讨论(0)
  • 2021-02-02 13:40

    I found a better way. Put This In Anywhere:

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

    And this does not make files in /runtime/debug

    0 讨论(0)
  • 2021-02-02 13:42

    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.

    0 讨论(0)
提交回复
热议问题