如何允许在Yii2中使用适当的(指定的)IP地址访问模块?
我试试,但是给出错误:
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: app\modules\getsp\getsp::allowedIPs
web.php
//....
'modules' => [
'getsp' => [
'class' => 'app\modules\getsp\getsp',
'allowedIPs' => ['127.0.0.1', '::1'],
],
],
//...
答案 0 :(得分:1)
尝试此解决方案可能会解决您的问题。
主-local.php
if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'getsp';
$config['modules']['getsp'] = 'yii\getsp\Module';
}
Main.php
'modules' => [
'getsp' => [
'class' => 'yii\getsp\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.1.*', 'XXX.XXX.XXX.XXX'] // The server machine ip is ex:-(192.168.1.102). or your PC PC ip address ex:-(192.168.1.101) adjust this to your needs
],
],