Since we started using mongoDB a while back, a large part of our PHP codebase looks like this:
$mongo = new Mongo();
$coll = $mongo->mydb->mycoll;
The default is to connect via TCP to localhost:27017
which has worked just fine for us for a few years now. Due to speed considerations, I would like to switch to using Unix domain sockets which are supported like this:
$client = new MongoClient("mongodb:///tmp/mongodb-27017.sock");
Is there a way to make this work without having to specify the socket file in the code? The docs list mongo.default_host
and mongo.default_port
which can be set in php.ini
so you can write:
$client = new MongoClient();
but that seems to be possible only for TCP connections. Or can I use these parameters to specify a socket file? If so, how?