The MongoDB\Driver\Manager class

简介

The MongoDB\Driver\Manager is the main entry point
to the extension. It is responsible for maintaining connections to MongoDB
(be it standalone server, replica set, or sharded cluster).

No connection to MongoDB is made upon instantiating the Manager.
This means the MongoDB\Driver\Manager can always be
constructed, even though one or more MongoDB servers are down.

Any write or query can throw connection exceptions as connections are created lazily.
A MongoDB server may also become unavailable during the life time of the script.
It is therefore important that all actions on the Manager to be wrapped in try/catch statements.

范例

var_dump()ing a
MongoDB\Driver\Manager will print out various
details about the manager that are otherwise not normally exposed.
This can be useful to debug how the driver views your MongoDB setup, and
which options are used.