开始使用yii2框架,相对于1有很大的变化,特别是配置有点不一样了。
yii2中配置文件入口为 {app path}/config/web.php
在默认生成的web.php最下面是这样的
if (YII_DEBUG) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = ['yii\gii\Module',];
}如果要使用,需要修改成如下,否则会出现403
if (YII_DEBUG) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '*.*.*.*'],
];
}注意区别在 $config['modules']['gii'] = [];
本文详细介绍了Yii2框架的配置方法,特别是在开发环境下如何正确配置debug模块和gii模块,确保开发者可以顺利进行代码调试和生成。

495

被折叠的 条评论
为什么被折叠?



