开始使用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'] = [];
---------------------
作者:秀能
来源:CSDN
原文:https://blog.csdn.net/xiunen_z/article/details/44807997