How To Disable Debug Toolbar on the specific page of Yii2
Preface
This article describes how to disable the Debug Toolbar in the debugging Toolbar on a specific page of Yii2. We will share the content for your reference. I will not talk about it much. Let's take a look at the detailed introduction:
The debugging Toolbar of yii2. You only need to configure it in the configuration file web. php to use it globally.
// configuration adjustments for 'dev' environment$config['bootstrap'][] = 'debug';$config['modules']['debug'] = [ 'class' => 'yii\debug\Module', // uncomment the following to add your IP if you are not connecting from localhost. //'allowedIPs' => ['127.0.0.1', '::1'],];
However, you may need to disable the debugging toolbar on a specific page.
Create Tools. php
namespace app\libs;use Yii;class Tools{ public static function DebugToolbarOff() { if (class_exists('\yii\debug\Module')) { Yii::$app->view->off(\yii\web\View::EVENT_END_BODY, [\yii\debug\Module::getInstance(), 'renderToolbar']); } }}
Directly call the tool bar where debugging needs to be disabled, such as an action.
use app\libs\Tools;……public function actionIndex(){ Tools::DebugToolbarOff(); return $this->render('index');}
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.