1

This is my connection code using old mongo php driver

$di->setShared('mongo', function () use ($config) {
    $mongoConfig = $config->mongo->toArray();
    $mongo = new MongoClient("mongodb://". $mongoConfig['host'] .":".$mongoConfig['port']);
    return $mongo->selectDB($mongoConfig['dbname']);
});
$di->setShared('collectionManager', function(){
    return new Phalcon\Mvc\Collection\Manager();
});

but the driver page display this warning

Warning This extension is deprecated. Instead, the MongoDB extension should be used.

How to convert the connection code for the new mongodb driver?

Marcelito Costa
  • 318
  • 4
  • 10

1 Answers1

1

To use the new MongoDB driver. First you need to make sure the Mongo extension is loaded in your PHP runtime. Second you need to get the new MongoDB driver and include it in your project.

Finally the code between the old and the new drivers are not compatible. Therefore you would need to rewrite the implementation and connection code.

Scriptonomy
  • 3,975
  • 1
  • 15
  • 23