0
votes

I installed the mongodb driver for PHP 7.2.23 includes the extension "extension = mongodb.so" in php.ini, phpinfo () returns that it is active, but when trying to connect to the database does not return the cluster data. Any one can help me?

Amazon Linux 2

Comands yum install php-pear yum install php-devel yum install mongo-c-driver pecl install mongodb

PHP code:

$mongo = new MongoDB\Driver\Manager("mongodb://user:[email protected]:28710,mongo2.com.br:28710,mongo3.com.br:28710/admin?replicaSet=rsMpsystems");

var_dump($mongo);

returns:

object(MongoDB\Driver\Manager)#1 (2) {
  ["uri"]=>
  string(195) "mongodb://mongodb://user:[email protected]:28710,mongo2.com.br:28710,mongo3.com.br:28710/admin?replicaSet=rsMpsystems"
  ["cluster"]=>
  array(0) {
  }
}

phpinfo() MongoDB support enabled MongoDB extension version 1.6.0 MongoDB extension stability stable libbson bundled version 1.15.1 libmongoc bundled version 1.15.1 libmongoc SSL enabled libmongoc SSL library OpenSSL libmongoc crypto enabled libmongoc crypto library libcrypto libmongoc crypto system profile disabled libmongoc SASL enabled libmongoc ICU disabled libmongoc compression enabled libmongoc compression snappy disabled libmongoc compression zlib enabled

1

1 Answers

0
votes

I Solved the problem!

$mongo = new MongoDB\Driver\Manager("mongodb://user:[email protected]:28710,mongo2.com.br:28710,mongo3.com.br:28710/admin?replicaSet=rsName");
$stats = new MongoDB\Driver\Command(["dbstats"=>1]);
$res = $mongo->executeCommand("db_name",$stats);
var_dump($res->toArray());

PHP 7.2.24 Amazon Linux 2 PECL mongodb 1.6.0 Done!