2014-12-05 58 views
3

簡單的問題,試圖啓用警予2〜GII遠程訪問 - 文件說http://www.yiiframework.com/doc-2.0/guide-start-gii.htmlYii的2.0啓用遠程訪問GII

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 
], 

事情是,它並沒有說在哪裏添加此 - guesing配置/ web.php

但是在哪一段?

回答

4

2個地方你需要添加這個。

通常是這樣做在你的主local.php

if (!YII_ENV_TEST) { 
    $config['bootstrap'][] = 'gii'; 
    $config['modules']['gii'] = [ 
     'class' => 'yii\gii\Module', 
    ]; 
} 

所以,你需要在配置的引導部分和模塊部分添加GII。這將打開它們基本上從你的配置追加到數組/ main.php 返回[ 'ID'=> '應用-後端', '基本路徑'=>目錄名(DIR) 'controllerNamespace'=> '後端\控制器', '自舉'=> [ '登錄'], '模塊'=> [ ], ],

在你給該鏈接,採取上述看看。你應該這樣做:

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 
]; 
} 
+0

我有這樣的配置/ web.php '如果 '開發' 環境 $配置(YII_ENV_DEV){// 配置調整[ '引導'] [] = '調試' ; $ config ['modules'] ['debug'] ='yii \ debug \ Module'; $ config ['bootstrap'] [] ='gii'; $ config ['modules'] ['gii'] ='yii \ gii \ Module'; }' – Adrian 2014-12-05 01:28:36

+0

謝謝 - 困惑我原來沒有'class => ..'那有效 – Adrian 2014-12-05 01:32:44