1
votes

I have done setup for mongodb on my system with Yii2 basic.

I have also installed the extension for mongodb (yii2-mongodb) inside a directory /vendor/yiisoft and checked for the permissions.

Now I am testing the connection with a controller and model but I am getting the following error.

PHP Fatal Error – yii\base\ErrorException Class

'yii\mongodb\ActiveRecord' not found

Is there anything that needs to be installed?

2
Did you install yii2-mongodb using composer? - Bizley
Yes I installed it using composer and on updating composer I am getting error i.e your requirements could not be resolved to an installable set of packages. - Swap
So it looks like you have not installed it. Probably you are missing MongoDB PHP extension. - Bizley
I am using PHP Version 7 and MongoDB extension version :1.2.8 is enabled. - Swap

2 Answers

1
votes

Have you install yii2/mongodb by composer ^^?

composer require --prefer-dist yiisoft/yii2-mongodb

Or your try follow this official Yii2 document step by step maybe can help you up :)!

1
votes

In this case I tried following command before updating composer to fulfill the packages that need to update the composer

sudo apt-get update
sudo apt-get install php7.0-xml

most likely you are missing mbstring too . If you get the error install this package as well.

sudo apt-get install php-mbstring

then run

composer require --prefer-dist yiisoft/yii2-mongodb
composer update

Will work!!!