Invalid Configuration – yii\base\InvalidConfigException

Patricia Heimfarth picture Patricia Heimfarth · Jan 1, 2015 · Viewed 21.4k times · Source

I'm using xampp for windows 8 and i have recently installed dektrium/yii2-user. I have followed the installation instructions here:

https://github.com/dektrium/yii2-user/blob/master/docs/installation.md

The changed part of my web.php looks now like this:

'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
            'class' => 'dektrium\user\Module',

        ],

I'm getting the error:

Missing required parameter "id" when instantiating "dektrium\user\Module".

And when I delete

    'class' => 'dektrium\user\Module',

the error disappears.

Answer

arogachev picture arogachev · Jan 1, 2015

Most likely you inserted this line in the wrong section (components):

'components' => [
    'user' => [
        'identityClass' => 'app\models\User',
        'enableAutoLogin' => true,
        // You inserted it here
    ],
],

But yii2-user is not component, it's module. Therefore you should include this in modules section of config. It also mentioned in documentation:

'modules' => [
    'user' => [
        'class' => 'dektrium\user\Module',
    ],
],

Right after installation basic application does not have any modules so in that case you should create this section by yourself.