How to disable the Debug toolbar in Yii2 specific Pages debug toolbar detailed

Source: Internet
Author: User
Tags yii
This article mainly introduces to you about how to disable Debugging Toolbar Debug toolbar in Yii2 specific page, the article through the detailed sample code introduced in very detailed, to everyone's study or work has a certain reference learning value, need to have a look at the friends below.

Objective

This article mainly introduces to you on the YII2 specific page disables debugging Toolbar debug toolbar related content, shares out for everybody reference study, words not to say, come together to see the detailed introduction:

The Yii2 Debug toolbar is an artifact. As long as it is configured in the configuration file web.php, it can be used globally

Configuration adjustments for ' dev ' environment$config[' bootstrap ' [] = ' debug '; $config [' Modules '] [' debug '] = [' Class ' = ' yii\debug\module ',//uncomment the following to add your IP if is not connecting from localhost. ' Allowedips ' = [' 127.0.0.1 ', ':: 1 '],];

However, there are times when you need to disable the Debug toolbar on a specific page.

New Tool Class 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 ']);  } }}

Where you need to disable the Debug toolbar, such as an action, call directly

Use App\libs\tools;......public function Actionindex () {Tools::D ebugtoolbaroff (); return $this->render (' Index ');}

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.