I try to use the driver 1.29 (https://pecl.php.net/package/mongodb/1.2.9) in PHP 5.7, as following codes:
$mongo = new MongoDBDriverManager('mongodb://localhost:27017');
$cmd = new MongoDBDriverCommand([
'aggregate' => 'collection',
'pipeline' => ['$group' => ['_id' => null, 'count' => ['$sum' => '$total']]]
]);
$rows = $mongo->executeCommand('database', $cmd);
foreach($rows as $r){
print_r($r);
}
it sometime saids:
Fatal error: Uncaught exception 'MongoDBDriverExceptionRuntimeException' with message ''pipeline' must be specified as an array'
sometime as :
Fatal error: Uncaught exception 'MongoDBDriverExceptionConnectionTimeoutException' with message 'No suitable servers found (`serverSelectionTryOnce` set): [socket timeout calling ismaster on '127.0.0.1:27017']'
PS: other command can be executed normally.