Jump to content

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".

 

<?php

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

 

 

 

 

<?php


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
    var_dump($m);
}
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
Quote

 

In this tutorial, he first downloads the "DLL" file and then downloads it with Composer.Then, to connect to Mango, it is added to the project by Composer.
I don't know what codes I should use to connect to the "dll" file

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.

Guest
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.