doctrine/mongodb

Allow to pass driver options to MongoClient

tlenclos opened this issue · 6 comments

Hi,
I can't find a way to pass driver options to the MongoClient class.

$this->mongoClient = $this->retry(function() use ($server, $options) {
    return new \MongoClient($server, $options);
});

$this->mongoClient = $this->retry(function() use ($server, $options) {

Second constructor argument in the same class you just linked:

public function __construct($server = null, array $options = [], Configuration $config = null, EventManager $evm = null)

I'm talking about the third argument of the MongoClient class which is $driver_options.

My apologies - I keep getting those two arguments confused. There is currently no way to pass in that option, unless you create the MongoClient object yourself and pass that as the first constructor argument. That way, you can set driverOptions directly.

@alcaeus and @tlenclos in my application I used connection options in Connection String, take a look:

mongodb://username:password@db1.example.net,db2.example.net:2500/?replicaSet=test&connectTimeoutMS=300000&otherOption=value

@tonicospinelli Thanks but this is also not the driver options, just the connections options. I will try to create the MongoClient object manually as @alcaeus said, but I think there should be an API available via this library (and the bundle).

@tlenclos Yes, definitely. I'll tag this as feature, however, we're not sure how we're continuing with this library as this builds on the legacy driver.