Rumah  >  Artikel  >  rangka kerja php  >  yii2怎么访问debug

yii2怎么访问debug

王林
王林asal
2020-03-11 13:52:532937semak imbas

yii2怎么访问debug

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 = [
    &#39;components&#39; => [
        &#39;log&#39; => [
            &#39;traceLevel&#39; => YII_DEBUG ? 3 : 0,
            &#39;targets&#39; => [
                [
                    &#39;class&#39; => &#39;yii\log\FileTarget&#39;,
                    &#39;levels&#39; => [&#39;error&#39;, &#39;warning&#39;],
                ],
            ],
        ],
    ],
];
 
if (YII_ENV_DEV) {
    // configuration adjustments for &#39;dev&#39; environment
    $localConfig[&#39;bootstrap&#39;][] = &#39;debug&#39;;
    $localConfig[&#39;modules&#39;][&#39;debug&#39;] = [
        &#39;class&#39; => &#39;yii\debug\Module&#39;,
        // uncomment the following to add your IP if you are not connecting from localhost.
        //&#39;allowedIPs&#39; => [&#39;127.0.0.1&#39;, &#39;::1&#39;],
        &#39;allowedIPs&#39; => [&#39;*&#39;],
    ];
 
    $localConfig[&#39;bootstrap&#39;][] = &#39;gii&#39;;
    $localConfig[&#39;modules&#39;][&#39;gii&#39;] = [
        &#39;class&#39; => &#39;yii\gii\Module&#39;,
        // uncomment the following to add your IP if you are not connecting from localhost.
        //&#39;allowedIPs&#39; => [&#39;127.0.0.1&#39;, &#39;::1&#39;],
    ];
}
 
return $localConfig;

5.设置runtime目录为可读写

Atas ialah kandungan terperinci yii2怎么访问debug. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn