Autoload configuration does not load MongoDB classes

I have MAMP 1.9 on MAC OSX 10.8.2 using PHP 5.3. I installed MongoDB and the PHP extension mongo.so and added it to my php.ini.

I can run MongoDB on the console, and my phpinfo says that MongoDB support is enabled, but I cannot run the following PHP script.

<?php $connection = new MongoClient(); ?>

PHP causes a fatal error:

Class 'MongoClient' not found

Something seems to be wrong in the startup configuration of my MAMP (or installing the extension).

+4
source share
2 answers

As Sammaye mentioned in the comments above, it looks like you are just running an older version of the driver. You can get the current version by resetting Mongo::VERSION or the return value from phpversion('mongo') . Instructions for installing / updating a drive through PECL are also documented ; however, we no longer have ready-made versions of GitHub (GitHub will soon remove the repository load, although we recently started publishing Windows builds on S3).

+2
source

I had the same problem because I was changing the wrong php.ini file. So I ran the following command

echo phpversion ('mongo');

and took the Loaded Configuration File , which was / Applications / MAMP / bin / php / php 5.4.4 / conf / php.ini and changed it.

Restarting Apache and it worked .yay !!!

0
source

All Articles