diff --git a/source/connect/client.txt b/source/connect/client.txt index bef37b50..793c1027 100644 --- a/source/connect/client.txt +++ b/source/connect/client.txt @@ -83,14 +83,36 @@ To learn more about connection strings, see :manual:`Connection Strings ` in the Server manual. -Create a MongoDB\Client ------------------------ +Create a MongoDB\\Client +------------------------ -To create a connection to MongoDB, pass your connection string when constructing -an instance of the ``MongoDB\Client`` class. +To create a connection to MongoDB, construct a ``MongoDB\Client`` object. +Pass the following parameters to the ``MongoDB\Client`` constructor: -In the following example, the library uses a sample connection URI to connect to a MongoDB -deployment on port ``27017`` of ``localhost``: +- ``$uri``: Sets the connection URI. + +- ``$uriOptions``: *(Optional)* Sets URI options to configure how the client + connects to MongoDB, including authentication credentials and + server selection settings. If you set the same options in this + parameter and in your connection string, the ``$uriOptions`` values + take precedence. To view a full list of supported options, see + the :ref:`php-connection-options` guide. + +- ``$driverOptions``: *(Optional)* Sets options to configure the behavior of the + underlying {+extension-short+}, including data encryption settings and certificate + validation options for TLS connections. To view a full list of supported options, + see :phpmethod:`MongoDB\Client::__construct()` in the API documentation. + +Example +~~~~~~~ + +This example constructs a client and passes the following parameters: + +- Connection URI, which connects to a MongoDB deployment on port ``27017`` + of ``localhost`` + +- URI options parameter, which instructs the {+library-short+} to wait + ``10000`` milliseconds for server selection before generating an error .. literalinclude:: /includes/connect/client.php :language: php diff --git a/source/includes/connect/client.php b/source/includes/connect/client.php index b5303dd1..ee2d337b 100644 --- a/source/includes/connect/client.php +++ b/source/includes/connect/client.php @@ -1,3 +1,6 @@ 10000]; + +$client = new MongoDB\Client($uri, $uriOptions); \ No newline at end of file