Home > PHP Framework > YII > body text

How to access debug in yii2

王林
Release: 2020-03-11 13:52:53
Original
3020 people have browsed it

How to access debug in yii2

1. Project installation debug tool

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

2. Configure web/index.php

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

3. Configure config/web.php

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

(Related tutorials recommended: yii framework)

4. Add 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;
Copy after login

5. Set the runtime directory to be readable and writable

The above is the detailed content of How to access debug in yii2. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template