When executing the following PHP code:
$m = new MongoClient("mongodb://localhost:27017");
I get the following error:
Fatal error: Class 'MongoClient' not found in (...)
MongoDB extension seems properly installed (I copied
php_mongodb.dll to ext folder and updated
PHP seems to confirm that the extension is running properly as the following code confirms it is loaded:
echo extension_loaded("mongodb") ? "loadedn" : "not loadedn";
phpinfo() shows that mongodb extension has been loaded.
UPDATE: my problem is still not solved.
phpinfo() clearly shows that the driver is loaded:
But I am still receiving the same fatal error.
MongoClientis part of the legacy PECL package mongo but not anymore of the up-to-date mongodb package.
And since you have the
mongodbextension installed, and not the
mongoone, this is why you are getting the error
On MongoDB PHP driver github repo, the release note about the version 1.0.0, is suggesting developers to use
So, here is the replacement class documentation and the snippet of code that should replace yours :
As the documentation is prompting it, the class is deprecated.
From what I read on their github repository release history, the class you are trying to use have been obsoleted since the version of
mongodb 1.0.0, so, on the version
1.6.0you are, this class is not even part of the
That is confirmed by this issue on their github
Another way, as suggested by the MongoDB member quoted here above is to use this pecl extension: https://pecl.php.net/package/mongo instead of https://pecl.php.net/package/mongodb but please also notice the warning there stating: