Hi guys!
I am a beginner developer and I have a some problem!
I need to use only mondodb as the main database. I tried many options.
But after executing the command yii migrate
i always get the exceptions.
Hi guys!
I am a beginner developer and I have a some problem!
I need to use only mondodb as the main database. I tried many options.
But after executing the command yii migrate
i always get the exceptions.
Please post these exceptions.
Exception ‘yii\base\InvalidConfigException’ with message ‘Failed to instantiate
component or class “db”.’
if i comment db section
Exception ‘yii\base\InvalidConfigException’ with message ‘“db” refers to a yii\mongodb\Connection component. yii\db\Connection is expected.’
if rename mongodb to db.
common\config\main-local.php
return [
'components' => [
// 'db' => [
// 'class' => 'yii\db\Connection',
// 'dsn' => 'mysql:host=localhost;dbname=yii',
// 'username' => 'root',
// 'password' => '',
// 'charset' => 'utf8',
// ],
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://@localhost:27017/yii',
'options' => [
'username' => '',
'password' => ''
]
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
],
];
Can you give a stacktrace for
Exception 'yii\base\InvalidConfigException' with
message '"db" refers to a yii\mongodb\Connection
component. yii\db\Connection is expected.'
?
hei i have the same problem, here my stacktrace
Exception ‘yii\base\InvalidConfigException’ with message ‘“db” refers to a yii\mongodb\Connection component. yii\db\Connection is expected.’
in C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\di\Instance.php:152
Stack trace:
#0 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2-queue\src\drivers\db\Queue.php(61): yii\di\Instance::ensure(Object(yii\di\Instance), ‘yii\db\Connecti…’)
#1 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\base\BaseObject.php(109): yii\queue\db\Queue->init()
#2 [internal function]: yii\base\BaseObject->__construct(Array)
#3 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\di\Container.php(419): ReflectionClass->newInstanceArgs(Array)
#4 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\di\Container.php(170): yii\di\Container->build(‘yii\queue\db\Qu…’, Array, Array)
#5 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\BaseYii.php(365): yii\di\Container->get(‘yii\queue\db\Qu…’, Array, Array)
#6 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\di\ServiceLocator.php(137): yii\BaseYii::createObject(Array)
#7 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\base\Module.php(766): yii\di\ServiceLocator->get(‘queue’, true)
#8 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\base\Application.php(311): yii\base\Module->get(‘queue’)
#9 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\base\Application.php(271): yii\base\Application->bootstrap()
#10 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\console\Application.php(124): yii\base\Application->init()
#11 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\base\BaseObject.php(109): yii\console\Application->init()
#12 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\base\Application.php(204): yii\base\BaseObject->__construct(Array)
#13 C:\xampp\htdocs\veristoreTools2\vendor\yiisoft\yii2\console\Application.php(89): yii\base\Application->__construct(Array)
#14 C:\xampp\htdocs\veristoreTools2\yii(19): yii\console\Application->__construct(Array)
#15 {main}