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 the MongoDB on the console and my phpinfo says MongoDB support is enabled but I cannot run the following PHP script.
<?php $connection = new MongoClient(); ?>
PHP comes up with a fatal error:
Class 'MongoClient' not found
Something seems to be wrong with the autoload configuration of my MAMP (or the extension installation).
As Sammaye mentioned in the comments above, it looks like you're simply running an older version of the driver. You can obtain the current version by either dumping Mongo::VERSION
or the returned value from phpversion('mongo')
. Instructions for installing/upgrading the drive via PECL are also documented; however, we no longer have pre-compiled versions available on GitHub (GitHub will soon be removing repository downloads, although we've recently begun publishing the Windows builds to S3).
I had the same issue because I was changing wrong php.ini file. So I ran the below command
echo phpversion('mongo');
and took Loaded Configuration File
which was /Applications/MAMP/bin/php/php5.4.4/conf/php.ini and changed it.
Restarted Apache and it worked.yay!!!
来源:https://stackoverflow.com/questions/14002074/autoload-configuration-doesnt-load-mongodb-classes