0

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 Answer 1

0

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.