简体   繁体   中英

Yii2 error - Class 'yii\mongodb\ActiveRecord' not found

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?

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 :)!

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!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM