Jump to content

Fatal error: Uncaught Error: Class "MongoClient" not found


Recommended Posts

hi.i installed mongodb and install "driver mongodb for php" from pecl.php.net.

when run this code , I am getting the error " Fatal error: Uncaught Error: Class "MongoClient" not found".



$m = new MongoClient();
echo "Connection to database successfully";
// select a database
$db = $m->examplesdb;
echo "Database examplesdb selected";





Link to comment
Share on other sites


try {
    // connect to OVHcloud Public Cloud Databases for MongoDB (cluster in version 4.4, MongoDB PHP Extension in 1.8.1)
    $m = new MongoDB\Driver\Manager('mongodb://localhost:27017');
    echo "Connection to database successfully";
    // display the content of the driver, for diagnosis purpose
catch (Throwable $e) {
    // catch throwables when the connection is not a success
    echo "Captured Throwable for connection : " . $e->getMessage() . PHP_EOL;

Solved, thanks

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.