Nana Partykar Nana Partykar - 5 months ago 117
PHP Question

Invalid Cofiguration - yii\base\InvalidConfigException - Yii2

I've just installed Yii2-User module/Dektrium to my Yii2-app-basic application by this command

composer require "dektrium/yii2-user:0.9.*@dev"


config/console.php

return [
.
.
'modules' => [
'gii' => 'yii\gii\Module',
'user' => [
'class' => 'dektrium\user\Module',
],
],
.
.
]


config/web.php

'components' => [
.
.
/*
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
*/
'modules' => [
'user' => [
'class' => 'dektrium\user\Module',
],
],
.
.
]


After that, i run this command
$ php yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations
for updating database schema .

But, when i run
http://localhost/mylawsuit/yii/web/index.php?r=user/registration/register
in my browser. It throws error:


Invalid Configuration – yii\base\InvalidConfigException

The configuration for the "modules" component must contain a "class"
element.


Screenshot of Error

enter image description here

And, when i'm changing web.php

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


Typing
http://localhost/mylawsuit/yii/web/index.php?r=user/registration/register
in my browser, it shows


Not Found (#404)

Page not found.


Screenshot

enter image description here

I'm not getting where i'm doing mistake. Please help me to rectify.

Answer

I Got answer.

I wrote 'modules'=>[...] inside 'components'=>[...], which was wrong.

Now, config/web.php

$config = [
  'id' => 'basic',
  'basePath' => dirname(__DIR__),
  'bootstrap' => ['log'],
  'components' => [
   .
   .
   .
   ],
  'modules' => [
    'user' => [
      'class' => 'dektrium\user\Module',
    ],
  ],
  'params' => $params,

Now, it's working fine.