首頁  >  文章  >  php框架  >  yii2怎麼訪問debug

yii2怎麼訪問debug

王林
王林原創
2020-03-11 13:52:532991瀏覽

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目錄為可讀寫

以上是yii2怎麼訪問debug的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn