一个简单的问题,尝试在yii 2中启用对gii的远程访问-文档说http://www.yiiframework.com/doc-2.0/guide-start-gii.html
Note: If you are accessing Gii from a machine other than localhost, the access will be denied by default for security purpose. You can configure Gii to add the allowed IP addresses as follows,
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
],
事实是,它没有说在哪里添加-猜测config/web.php
但是在什么部分下?
最佳答案
您需要添加2个地方。
通常在您的main-local.php中是这样完成的
if (!YII_ENV_TEST) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
因此,您需要在配置的bootstrap部分和modules部分中添加gii。这将使它们基本上从您的config/main.php添加到数组中
返回 [
'id'=>'应用程序后端',
'basePath'=> dirname( DIR ),
'controllerNamespace'=>'后端\ Controller ',
'bootstrap'=> ['log'],
'模块'=> [
],
],
在您给的链接上,看看上面。你应该做:
if (YII_ENV_DEV) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
];
}
关于yii2 - Yii 2.0支持对Gii的远程访问,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27306727/