对象配置必须是包含"class"元素的数组. yii2中的元素与mongodb [英] Object configuration must be an array containing a "class" element in yii2 with mongodb
本文介绍了对象配置必须是包含"class"元素的数组. yii2中的元素与mongodb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误>使用 yii2 + mongodb 登录或注册时出现错误.
Error > while login or signup using yii2+ mongodb gives an error.
与yii2的MongoDB连接已完成.请帮助我解决这个问题.
MongoDB connection with yii2 is done. please help me to solve this problem.
main-local.php
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,
],
],
];
推荐答案
检查您的供应商\ yiisoft \ extension.php 安装了一个将不正确的配置数组添加到文件vendor \ yiisoft \ extension.php
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',
)
),
这篇关于对象配置必须是包含"class"元素的数组. yii2中的元素与mongodb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文