当前位置:Gxlcms > php框架 > yii2怎么访问debug

yii2怎么访问debug

时间:2021-07-01 10:21:17 帮助过:46人阅读

1.项目安装debug工具

  1. php composer.phar require --prefer-dist yiisoft/yii2-debug

2.配置web/index.php

  1. defined('YII_DEBUG') or define('YII_DEBUG', true);
  2. defined('YII_ENV') or define('YII_ENV', 'dev');

3.配置config/web.php

  1. if(file_exists(__DIR__ . "/web-local.php")) {
  2. $localConfig = require __DIR__ . "/web-local.php";
  3. $config = ArrayHelper::merge($config, $localConfig);
  4. }

(相关教程推荐:yii框架)

4.增加web-local.php

  1. <?php
  2. $localConfig = [
  3. 'components' => [
  4. 'log' => [
  5. 'traceLevel' => YII_DEBUG ? 3 : 0,
  6. 'targets' => [
  7. [
  8. 'class' => 'yii\log\FileTarget',
  9. 'levels' => ['error', 'warning'],
  10. ],
  11. ],
  12. ],
  13. ],
  14. ];
  15. if (YII_ENV_DEV) {
  16. // configuration adjustments for 'dev' environment
  17. $localConfig['bootstrap'][] = 'debug';
  18. $localConfig['modules']['debug'] = [
  19. 'class' => 'yii\debug\Module',
  20. // uncomment the following to add your IP if you are not connecting from localhost.
  21. //'allowedIPs' => ['127.0.0.1', '::1'],
  22. 'allowedIPs' => ['*'],
  23. ];
  24. $localConfig['bootstrap'][] = 'gii';
  25. $localConfig['modules']['gii'] = [
  26. 'class' => 'yii\gii\Module',
  27. // uncomment the following to add your IP if you are not connecting from localhost.
  28. //'allowedIPs' => ['127.0.0.1', '::1'],
  29. ];
  30. }
  31. return $localConfig;

5.设置runtime目录为可读写

以上就是yii2怎么访问debug的详细内容,更多请关注Gxlcms其它相关文章!

人气教程排行