• 技术文章 >php框架 >YII

    yii2怎么访问debug

    王林王林2020-03-11 13:52:53原创1421

    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

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

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

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:yii2 debug
    上一篇:yii框架怎么使用twig模板引擎 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • yii怎么引入图片资源• yii怎么获取post参数?• yii怎么设置默认路由?• yii框架怎么使用twig模板引擎
    1/1

    PHP中文网