Trying to create a new Mongo connection using the following: $client = new Mongo();
Sadly, this results in the following error: "Uncaught Error: Class 'Mongo' not found in". I've also tried MongoClient, just in case this is the issue.
To make things more confusing, running phpinfo() in the same file results in the following.
Any help would be greatly appreciated.
There are two PHP MongoDB packages, the Mongo extension and the newer MongoDB driver . You have the newer one, but you're writing code for the older one.
Turns out that this is an issue in the official driver documentation.
You need to use new MongoDB\\Client
and use the PHP library as well, rather than new MongoDB\\Driver\\Client
as suggested.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.