Question

I am using Yii 2.. In my main-local.php file:

'modules' => [
    'debug' => 'yii\debug\Module',
    'gii' => 'yii\gii\Module',
],
    'gii' => [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '50.62.10.149', '50.63.59.230']
    ]

What could be the reason for error like:

Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: yii\web\Application::gii
Was it helpful?

Solution 2

Try it like this instead. (If you want to include more parameters other than the class, you have to use an array instead.)

'modules' => [
    'debug' => 'yii\debug\Module', // Think of this as a shortcut syntax.
    'gii' => [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '50.62.10.149', '50.63.59.230']
    ]
],

You have to put all module configuration inside the modules-array. The error is pretty much self explaining. You are trying to use the property yii\web\Application::gii, but there is no such thing. You have to use yii\web\Application::modules instead

OTHER TIPS

I know it is an older question but I've been stuck here too , and to get this working fine it's not enough to define gii component only in your main file , it must be defined in main-local too :

if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '50.62.10.149'],
    ];
}
return $config;

I had to do the same as KB9 for Yii 2.0.1. The only difference is that this code block is now in confg/web.php file:

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '1.2.3.4'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '1.2.3.4'],
    ];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top