1

How do I turn the debug bar off in Yii2? I tried

<?php
use app\assets\AppAsset;
define('YII_DEBUG', false);
AppAsset::register($this);
$this->beginPage() ?>
<!DOCTYPE html>

But it gave an error Constant YII_DEBUG already defined. I don't want to turn it off for the whole app, just that view.

Tried Yii::$app->modules['debug'] = null; and got

PHP Notice – yii\base\ErrorException Indirect modification of overloaded property yii\web\Application::$modules has no effect

This executed, but the debug bar still shows.

$modules = Yii::$app->modules;
$module['debug'] = null; 
Yii::$app->setModules($modules);
Chloe
  • 25,162
  • 40
  • 190
  • 357

0 Answers0