Search code examples
phpyiigiiyii2

yii 2: gii index page loading issue


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

Solution

  • 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