如何在Yii2中启用调试模式?

时间:2017-07-13 17:52:17

标签: yii2

我有基本版本。我阅读了文章http://www.yiiframework.com/doc-2.0/yii-debug-module.html,但我不明白在哪个文件中插入代码,包括调试?

我搜索了这些信息,发现在config / web.php中 现在我在YII_ENV_DEV部分中编写调试,如下所示:

  private static String getCoverArtPath(long albumId, Context context) {

    Cursor albumCursor = context.getContentResolver().query(
            MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
            new String[]{MediaStore.Audio.Albums.ALBUM_ART},
            MediaStore.Audio.Albums._ID + " = ?",
            new String[]{Long.toString(albumId)},
            null
    );
    boolean queryResult = albumCursor.moveToFirst();
    String result = null;
    if (queryResult) {
        result = albumCursor.getString(0);
    }
    albumCursor.close();
    return result;
}

应用程序/网页/ index.php的

if (YII_ENV_DEV) {
    // 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' => ['85.89.139.124'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        //'allowedIPs' => ['127.0.0.1', '::1'],
    ];
}

但它不起作用,我只看到404错误。

1 个答案:

答案 0 :(得分:3)

检查你的app / web / index.php并确保你有

 <?php
       defined('YII_DEBUG') or define('YII_DEBUG', true);
       defined('YII_ENV') or define('YII_ENV', 'dev');
         ........