Home >PHP Framework >YII >How to access debug in yii2
1. Project installation debug tool
php composer.phar require --prefer-dist yiisoft/yii2-debug
2. Configure web/index.php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev');
3. Configure config/web.php
if(file_exists(__DIR__ . "/web-local.php")) { $localConfig = require __DIR__ . "/web-local.php"; $config = ArrayHelper::merge($config, $localConfig); }
(Related tutorials recommended: yii framework)
4. Add web-local.php
<?php $localConfig = [ 'components' => [ 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], ], ]; if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment $localConfig['bootstrap'][] = 'debug'; $localConfig['modules']['debug'] = [ 'class' => 'yii\debug\Module', // uncomment the following to add your IP if you are not connecting from localhost. //'allowedIPs' => ['127.0.0.1', '::1'], 'allowedIPs' => ['*'], ]; $localConfig['bootstrap'][] = 'gii'; $localConfig['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'], ]; } return $localConfig;
5. Set the runtime directory to be readable and writable
The above is the detailed content of How to access debug in yii2. For more information, please follow other related articles on the PHP Chinese website!