对象配置必须是一个包含“类"的数组.yii2 中的元素与 mongodb [英] Object configuration must be an array containing a "class" element in yii2 with mongodb

查看:16
本文介绍了对象配置必须是一个包含“类"的数组.yii2 中的元素与 mongodb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Error > 使用 yii2+ mongodb 登录或注册时出现错误.

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

MongoDB 与 yii2 的连接完成.请帮我解决这个问题.

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

main-local.php

main-local.php

return [
    'components' => [
            'mongodb' => [
            'class' => 'yiimongodbConnection',
            'dsn' => 'mongodb://sameer:27017/demo',
        ],
        'mailer' => [
            'class' => 'yiiswiftmailerMailer',
            'viewPath' => '@common/mail',
             'useFileTransport' => true,
        ],
    ],
];

main.php

return [
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'components' => [
        'cache' => [
            'class' => 'yiicachingFileCache',
        ],
        'user' => [
                'identityClass' => 'commonmodelsUser',
                'enableAutoLogin' => false,
            ],
    ],
];

推荐答案

检查你的 vendoryiisoftextension.php在我安装了一个将不正确的配置数组添加到文件 vendoryiisoftextension.php 的软件包后,我遇到了同样的错误

Check your vendoryiisoftextension.php I had the same error after I had installed one package which add uncorrect config array to the file vendoryiisoftextension.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',
         )
     ),

这篇关于对象配置必须是一个包含“类"的数组.yii2 中的元素与 mongodb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆