Object configuration must be an array containing a “class” element in yii2 with mongodb

限于喜欢 提交于 2019-12-02 16:18:10

问题


Error > while login or signup using yii2+ mongodb gives an error.

MongoDB connection with yii2 is done. please help me to solve this problem.

main-local.php

return [
    'components' => [
            'mongodb' => [
            'class' => '\yii\mongodb\Connection',
            'dsn' => 'mongodb://sameer:27017/demo',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
             'useFileTransport' => true,
        ],
    ],
];

main.php

return [
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'components' => [
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
                'identityClass' => 'common\models\User',
                'enableAutoLogin' => false,
            ],
    ],
];

回答1:


Check your vendor\yiisoft\extension.php I had the same error after I had installed one package which add uncorrect config array to the file vendor\yiisoft\extension.php

'tigrov/yii2-country' =>
     array (
        'name' => 'tigrov/yii2-country',
        'version' => '9999999-dev',
        'alias' =>
         array (
           '@tigrov/country' => $vendorDir . '/tigrov/yii2-country/src',
         ),
        'bootstrap' => 'tigrov\\country\\Bootstrap',
     ),

I've changed the previous one to the next one (just wrapped bootstrap in array)

'tigrov/yii2-country' =>
     array (
        'name' => 'tigrov/yii2-country',
        'version' => '9999999-dev',
        'alias' =>
         array (
            '@tigrov/country' => $vendorDir . '/tigrov/yii2-country/src',
         ),
         array(
            'bootstrap' => 'tigrov\\country\\Bootstrap',
         )
     ),


来源:https://stackoverflow.com/questions/45500828/object-configuration-must-be-an-array-containing-a-class-element-in-yii2-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!