integrating php with mongoDB DB

Asked

Viewed 75 times

-1

I’m running a test to save the site information in the database and the code I wrote to see if the PHP and the bank are connected was that:

<?php
    $mng = new MongoDB\Driver\Manager("mongodb://login-hpfbn.gcp.mongodb.net:27017");
    $stats = new MongoDB\Driver\Command(["dbstats" => 1]);
    $res = $mng->executeCommand("phpbasic", $stats);
    $stats = current($res->toArray());
    print_r($stats); 
?>

and the site is showing me this error:

Fatal error: Uncaught Error: Class 'Mongodb Driver Manager' not found in C: xampp htdocs phpmongo test.php:4 Stack trace: #0 {main} thrown in C: xampp htdocs phpmongo test.php on line 4

1 answer

1

Missing mongodb module in PHP. To install the mongodb module you will need:

Install by PECL:

sudo pecl install mongodb

In php.ini insert this:

extension=mongodb.so

Browser other questions tagged

You are not signed in. Login or sign up in order to post.