How to change from Debug to Production

I dont get it…Debug and Production-Mode in Yii 2 Advanced Template:

I read, that i have to delete the following code for change to Production mode.

if (!YII_ENV_TEST) {

    // configuration adjustments for 'dev' environment

    $config['bootstrap'][] = 'debug';

    $config['modules']['debug'] = [

        'class' => 'yii\debug\Module',


    $config['bootstrap'][] = 'gii';

    $config['modules']['gii'] = [

        'class' => 'yii\gii\Module',

        'allowedIPs' => ['*'],



but are the following Lines??

I red also that i have to change true to false for Production Mode… but when i change to true… Nothing happens still get the debug bar

defined('YII_DEBUG') or define('YII_DEBUG', true);

defined('YII_ENV') or define('YII_ENV', 'dev');

now my question is, when i have to remove the code in de config file… for what is the code in the index.php??

thank you

allright i just found my Problem YII_ENV_TEST is not YII_DEBUG

So if i call it YII_ENV_TEST or YII_DEBUG doesnt matter? its just a name?

It’s better to set YII_DEBUG to false and YII_ENV to proper environment such as “production”.

1 Like