简单的问题,试图在yii 2中启用远程访问gii - docs 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
],
Run Code Online (Sandbox Code Playgroud)
事情是,它没有说明在哪里添加 - 猜猜配置/ web.php
但是在哪个部分?
您需要添加2个地方.
通常在main-local.php中这样做
if (!YII_ENV_TEST) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
Run Code Online (Sandbox Code Playgroud)
所以你需要在配置的bootstrap部分和模块部分添加gii.这将基本上将它们从config/main.php返回到数组返回['id'=>'app-backend','basePath'=> dirname(DIR),'controllerNamespace'=>'backend\controllers', 'bootstrap'=> ['log'],'modules'=> [],],
在您提供的链接上,请查看上面的内容.你应该做:
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
];
}
Run Code Online (Sandbox Code Playgroud)