Using Mongo in Yii

I’m a newbie here. I’m trying to use Mongo directly in my Yii application (without using any of the mongodb extensions specific to yii). I’m getting “include(Mongo.php): failed to open stream: No such file or directory” error at the following line in my code:

  $m = new Mongo();

I have installed the PHP Mongodb driver and I’m able to use it in a standalone PHP script without any issues.

Can anyone please tell me what is wrong?


Mongo is a PECL extension … would check the output of phpinfo() via your Yii app to confirm there is a section for ‘mongo’ included. It’s possible (particularly on linux) that you added the mongo extension to a php.ini used by the command line which may be different from the php.ini used by your web server.

Thanks stennie. I checked output from phpinfo() from inside my yii app. It shows that it reads additional .ini files from /etc/php.d/ directory where my mongo.ini resides. However, in the .ini files listed by the phpinfo() output, all files are present except mongo.ini.

What could be wrong?


After a machine reboot, it works fine.