热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

yii2怎么访问debug

yii2访问debug的方法:1、项目安装debug工具;2、配置webindex.php;3、配置configweb.php;4、增加web-local.php;5、设置runtime目录为可读写。

1.项目安装debug工具

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

2.配置web/index.php

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

3.配置config/web.php

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

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

4.增加web-local.php

 [
        '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.设置runtime目录为可读写

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


推荐阅读
author-avatar
哎呦我去2502859031
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有