Nana Partykar
Nana Partykar

Reputation: 10548

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.

Upvotes: 4

Views: 7065

Answers (2)

Paul Burak
Paul Burak

Reputation: 1

If u rewrote user model and ['/user/security/login'] redirecting to '/user/login' with 404, open web config and look for 'urlManager' component. If you have enblePrettyUrl on, look on rules. The problem is there - change it or delete.

Upvotes: 0

Nana Partykar
Nana Partykar

Reputation: 10548

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.

Upvotes: 3

Related Questions