简体   繁体   English

Yii2错误-找不到类'yii \\ mongodb \\ ActiveRecord'

[英]Yii2 error - Class 'yii\mongodb\ActiveRecord' not found

I have done setup for mongodb on my system with Yii2 basic. 我已经使用Yii2 basic在我的系统上完成了mongodb的设置。

I have also installed the extension for mongodb (yii2-mongodb) inside a directory /vendor/yiisoft and checked for the permissions. 我还在目录/ vendor / yiisoft内安装了mongodb的扩展名(yii2-mongodb),并检查了权限。

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 PHP致命错误– yii \\ base \\ ErrorException类

'yii\\mongodb\\ActiveRecord' not found 找不到'yii \\ mongodb \\ ActiveRecord'

Is there anything that needs to be installed? 是否需要安装任何东西?

Have you install yii2/mongodb by composer ^^? 您是否已通过作曲家^^安装yii2 / mongodb?

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

Or your try follow this official Yii2 document step by step maybe can help you up :)! 或者您可以尝试逐步遵循此Yii2官方文档 ,也许可以帮助您:)!

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 . 很可能您也缺少mbstring。 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!!! 将工作!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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