Disable debug module dynamically

Hi,

Is there a way to disable debug module from the inside of e.g a controller?

It’s inconvenient to manipulate IP filter in the bootstrap each time some issue is showing. Debug module consumes a remarkable amount of memory and is often a source of memory-related fatal error itself.

It would be nice to have a possibility to disable debug log from the code.

Any idea?
Ziggi

Not really but you can hack it:

index.php:

defined('YII_DEBUG') or define('YII_DEBUG', require 'debug.php`);

debug.php:

<?php

return true;

The controller may do:

file_put_contents('debug.php', "<?php\n" . var_export($debugEnabled));
1 Like

you can also do this:

foreach(\Yii::$app->log->targets as $target){
        $target->setEnabled(false);
    }
2 Likes

Thank you !!!