How To Disable Debug Toolbar on the specific page of Yii2

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.