mdmsoft / yii2-admin

Auth manager for Yii2 (RBAC Manager)
GNU General Public License v3.0
1.16k stars 577 forks source link

Missing required parameter "id" when instantiating "mdm\admin\Module". #38

Closed fimak closed 10 years ago

fimak commented 10 years ago

I get error "Missing required parameter "id" when instantiating "mdm\admin\Module"." when try to install this module. I have installed it how it described in instruction.

mdmunir commented 10 years ago

what version that you are used? provide your configurasion and error trace.

fimak commented 10 years ago

inside the composer.json:

"require": {
        "yiisoft/yii2": "*",
                "mdmsoft/yii2-admin": "*"

inside the common/config/mian.php:

return [
    'modules' => [
        'admin' => [
            'class' => 'mdm\admin\Module',
        ]
        ...
    ],
    ...
    'components' => [
        ....
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ]
    ],
    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'admin/*',
        ]
    ],
];

Error trace:

Invalid Configuration – yii\base\InvalidConfigException

Missing required parameter "id" when instantiating "mdm\admin\Module".
1. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php at line 444
435436437438439440441442443444445446447448449450    protected function resolveDependencies($dependencies, $reflection = null)
    {
        foreach ($dependencies as $index => $dependency) {
            if ($dependency instanceof Instance) {
                if ($dependency->id !== null) {
                    $dependencies[$index] = $this->get($dependency->id);
                } elseif ($reflection !== null) {
                    $name = $reflection->getConstructor()->getParameters()[$index]->getName();
                    $class = $reflection->getName();
                    throw new InvalidConfigException("Missing required parameter \"$name\" when instantiating \"$class\".");
                }
            }
        }
        return $dependencies;
    }
}
2. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php – yii\di\Container::resolveDependencies([yii\di\Instance, null, []], ReflectionClass) at line 363
3. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php – yii\di\Container::build('mdm\admin\Module', [], []) at line 147
4. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php – yii\di\Container::get('mdm\admin\Module') at line 440
5. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php – yii\di\Container::resolveDependencies([yii\di\Instance, ['allowActions' => ['admin/*']]], ReflectionClass) at line 363
6. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php – yii\di\Container::build('mdm\admin\components\AccessContr...', [], ['allowActions' => ['admin/*']]) at line 147
7. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/BaseYii.php – yii\di\Container::get('mdm\admin\components\AccessContr...', [], ['allowActions' => ['admin/*']]) at line 344
8. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/base/Component.php – yii\BaseYii::createObject(['class' => 'mdm\admin\components\AccessContr...', 'allowActions' => ['admin/*']]) at line 180
9. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/BaseYii.php – yii\base\Component::__set('as access', ['class' => 'mdm\admin\components\AccessContr...', 'allowActions' => ['admin/*']]) at line 518
10. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/base/Object.php – yii\BaseYii::configure(yii\web\Application, ['extensions' => ['yiisoft/yii2-swiftmailer' => ['name' => 'yiisoft/yii2-swiftmailer', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/swiftmailer' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-codeception' => ['name' => 'yiisoft/yii2-codeception', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/codeception' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-bootstrap' => ['name' => 'yiisoft/yii2-bootstrap', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/bootstrap' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-debug' => ['name' => 'yiisoft/yii2-debug', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/debug' => '/home/fimak/web/tradesimple/vend...']], ...], 'components' => ['cache' => ['class' => 'yii\caching\FileCache'], 'request' => ['enableCookieValidation' => true, 'enableCsrfValidation' => true, 'cookieValidationKey' => 'xxxxxxx', 'class' => 'yii\web\Request'], 'authManager' => ['class' => 'yii\rbac\DbManager'], 'db' => ['class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=trad...', 'username' => 'root', 'password' => 'toor', ...], ...], 'modules' => ['admin' => ['class' => 'mdm\admin\Module'], 'crm' => ['class' => 'app\modules\crm\Module'], 'debug' => 'yii\debug\Module', 'gii' => 'yii\gii\Module'], 'as access' => ['class' => 'mdm\admin\components\AccessContr...', 'allowActions' => ['admin/*']], ...]) at line 105
11. in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/base/Application.php – yii\base\Object::__construct(['extensions' => ['yiisoft/yii2-swiftmailer' => ['name' => 'yiisoft/yii2-swiftmailer', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/swiftmailer' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-codeception' => ['name' => 'yiisoft/yii2-codeception', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/codeception' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-bootstrap' => ['name' => 'yiisoft/yii2-bootstrap', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/bootstrap' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-debug' => ['name' => 'yiisoft/yii2-debug', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/debug' => '/home/fimak/web/tradesimple/vend...']], ...], 'components' => ['cache' => ['class' => 'yii\caching\FileCache'], 'request' => ['enableCookieValidation' => true, 'enableCsrfValidation' => true, 'cookieValidationKey' => 'xxxxxxx', 'class' => 'yii\web\Request'], 'authManager' => ['class' => 'yii\rbac\DbManager'], 'db' => ['class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=trad...', 'username' => 'root', 'password' => 'toor', ...], ...], 'modules' => ['admin' => ['class' => 'mdm\admin\Module'], 'crm' => ['class' => 'app\modules\crm\Module'], 'debug' => 'yii\debug\Module', 'gii' => 'yii\gii\Module'], 'as access' => ['class' => 'mdm\admin\components\AccessContr...', 'allowActions' => ['admin/*']], ...]) at line 202
12. in /home/fimak/web/tradesimple/backend/web/index.php – yii\base\Application::__construct(['vendorPath' => '/home/fimak/web/tradesimple/vend...', 'extensions' => ['yiisoft/yii2-swiftmailer' => ['name' => 'yiisoft/yii2-swiftmailer', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/swiftmailer' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-codeception' => ['name' => 'yiisoft/yii2-codeception', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/codeception' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-bootstrap' => ['name' => 'yiisoft/yii2-bootstrap', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/bootstrap' => '/home/fimak/web/tradesimple/vend...']], 'yiisoft/yii2-debug' => ['name' => 'yiisoft/yii2-debug', 'version' => '2.0.0.0-RC', 'alias' => ['@yii/debug' => '/home/fimak/web/tradesimple/vend...']], ...], 'components' => ['cache' => ['class' => 'yii\caching\FileCache'], 'request' => ['enableCookieValidation' => true, 'enableCsrfValidation' => true, 'cookieValidationKey' => 'xxxxxxx'], 'authManager' => ['class' => 'yii\rbac\DbManager'], 'db' => ['class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=trad...', 'username' => 'root', 'password' => 'toor', ...], ...], 'modules' => ['admin' => ['class' => 'mdm\admin\Module'], 'crm' => ['class' => 'app\modules\crm\Module'], 'debug' => 'yii\debug\Module', 'gii' => 'yii\gii\Module'], ...])
mdmunir commented 10 years ago

what minimum-stability of your composer.json?

fimak commented 10 years ago

"minimum-stability": "beta",

mdmunir commented 10 years ago

got it. beta is expired. use dev version. "minimum-stability": "dev", or change "mdmsoft/yii2-admin": "*" to "mdmsoft/yii2-admin": "dev-master"

fimak commented 10 years ago

Thanks.

ivancse58 commented 10 years ago

hi i am having same problem. for "minimum-stability": "RC", i used "mdmsoft/yii2-admin": "@dev". it downloaded but error occur. what to do?

mdmunir commented 10 years ago

@ivancse58 how about "mdmsoft/yii2-admin": "dev-master"?

gadelkareem commented 9 years ago

Getting the same here with mdmsoft/yii2-admin (dev-master 6973eca) config:

 'components' => [
        'i18n' => [
            'translations' => [
                'rbac-admin' => [
                    'class' => 'mdm\admin\Module',
                    'sourceLanguage' => 'en',
                    'basePath' => '@mdm/admin/messages'
                ]
            ]
        ],
    ],
    'modules' => [
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],
        'admin' => [
            'class' => 'mdm\admin\Module',
            'layout' => 'left-menu', // default to null. other avaliable value 'right-menu' and 'top-menu'
            'controllerMap' => [
                'assignment' => [
                    'class' => 'mdm\admin\controllers\AssignmentController',
                    'userClassName' => 'common\models\User',
                    'idField' => 'id'
                ]
            ],
            'menus' => [
                'assignment' => [
                    'label' => 'Grand Access' // change label
                ],
                'route' => null, // disable menu
            ],
        ],
    ],