@@ -39,6 +39,9 @@ Errors/Exceptions
3939Examples
4040--------
4141
42+ Connecting to a Replica Set
43+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
44+
4245If you do not specify a ``$uri`` value, the driver connects to a standalone
4346:program:`mongod` on ``127.0.0.1`` via port ``27017``. The following example
4447demonstrates how to connect to a replica set with a custom read preference:
@@ -54,6 +57,48 @@ demonstrates how to connect to a replica set with a custom read preference:
5457 ]
5558 );
5659
60+ Connecting with SSL and Authentication
61+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62+
63+ The following example demonstrates how to connect to a MongoDB replica set with
64+ SSL and authentication, as is used for `MongoDB Atlas
65+ <https://cloud.mongodb.com/?jmp=docs>`_:
66+
67+ .. code-block:: php
68+
69+ <?php
70+
71+ $client = new MongoDB\Client(
72+ 'mongodb://myUsername:myPassword@rs1.example.com,rs2.example.com/?ssl=true&replicaSet=myReplicaSet&authSource=admin'
73+ );
74+
75+ Alternatively, the authentication credentials and URI parameters may be
76+ specified in the constructor's ``$uriOptions`` parameter:
77+
78+ .. code-block:: php
79+
80+ <?php
81+
82+ $client = new MongoDB\Client(
83+ 'mongodb://rs1.example.com,rs2.example.com/'
84+ [
85+ 'username' => 'myUsername',
86+ 'password' => 'myPassword',
87+ 'ssl' => true,
88+ 'replicaSet' => 'myReplicaSet',
89+ 'authSource' => 'admin',
90+ ],
91+ );
92+
93+ The driver supports additional :php:`SSL options
94+ <mongodb-driver-manager.construct#mongodb-driver-manager.construct-driveroptions>`,
95+ which may be specified in the constructor's ``$driverOptions`` parameter. Those
96+ options are covered in the :php:`MongoDB\\Driver\\Manager::__construct()
97+ <mongodb-driver-manager.construct>` documentation.
98+
99+ Specifying a Custom Type Map
100+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101+
57102By default, the |php-library| deserializes BSON documents and arrays
58103as :phpclass:`MongoDB\\Model\\BSONDocument` and
59104:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively. The following
0 commit comments