Skip to content

Commit 1df7cf0

Browse files
committed
formatting
1 parent 45739f4 commit 1df7cf0

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ php-library = "MongoDB PHP Library"
2525
[constants]
2626
php-library = "MongoDB PHP Library"
2727
api = "https://www.mongodb.com/docs/php-library/current/reference"
28+
driver-short = "PHP library"
2829
string-data-type = "``string``"
2930
bool-data-type = "``bool``"
3031
int-data-type = "``int``"

source/connect/connection-options.txt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ You can configure your connection by specifying options in the connection URI or
3030
passing them to the ``MongoDB\Client`` constructor.
3131

3232
.. TODO:
33-
how uri object overrides uri
34-
- finish intro text
33+
-code samples
34+
- fix table widths
3535

3636
.. _php-connection-uri:
3737

@@ -52,8 +52,8 @@ the connection URI contains the ``tls`` option with a value of ``true`` and the
5252

5353
.. _php-client-object:
5454

55-
Using a MongoDB\Client Object
56-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
Using a MongoDB\\Client Object
56+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5757

5858
You can pass connection options to the ``MongoDB\Client`` constructor
5959
instead of including them in your connection URI.
@@ -70,6 +70,11 @@ The following example shows how to use the the ``$uriOptions`` parameter of the
7070
:end-before: // end-client-options
7171
:emphasize-lines: 8-12, 15
7272

73+
.. note::
74+
75+
If you specify an option in both the ``MongoDB\Client`` object and in the connection
76+
URI, the value in the ``MongoDB\Client`` object takes precedence.
77+
7378
Connection URI Options
7479
----------------------
7580

@@ -135,6 +140,7 @@ Compression Options
135140
.. list-table::
136141
:header-rows: 1
137142
:stub-columns: 1
143+
:widths: 20 10 70
138144

139145
* - Connection Option
140146
- Data Type
@@ -148,6 +154,7 @@ Compression Options
148154
* - :manual:`zlibCompressionLevel </reference/connection-string/#mongodb-urioption-urioption.zlibcompressionlevel>`
149155
- {+int-data-type+}
150156
- | **MongoDB\Client**: ``$uriOptions = [ 'compressors' => 'snappy,zstd,zlib', 'zlibCompressionLevel' => 3 ];``
157+
|
151158
| **Connection URI**: ``compressors=snappy,zstd,zlib&zlibCompressionLevel=3``
152159

153160
Connection Pool Options
@@ -163,11 +170,13 @@ Connection Pool Options
163170

164171
* - :manual:`maxPoolSize </reference/connection-string/#mongodb-urioption-urioption.maxpoolsize>`
165172
- {+int-data-type+}
166-
- | **Connection URI**: ``maxPoolSize=75``
173+
- | **MongoDB\Client**: N/A
174+
| **Connection URI**: ``maxPoolSize=75``
167175

168176
* - :manual:`waitQueueTimeoutMS </reference/connection-string/#mongodb-urioption-urioption.waitqueuetimeoutms>`
169177
- {+int-data-type+}
170-
- | **Connection URI**: ``waitQueueTimeoutMS=10000``
178+
- | **MongoDB\Client**: N/A
179+
| **Connection URI**: ``waitQueueTimeoutMS=10000``
171180

172181
Write Concern Options
173182
~~~~~~~~~~~~~~~~~~~~~
@@ -217,13 +226,14 @@ Read Preference Options
217226
.. list-table::
218227
:header-rows: 1
219228
:stub-columns: 1
229+
:widths: 20 20 60
220230

221231
* - Connection Option
222232
- Data Type
223233
- Syntax
224234

225235
* - :manual:`readPreference </reference/connection-string/#mongodb-urioption-urioption.readpreference>`
226-
- `MongoDB\Driver\ReadPreference <https://www.php.net/manual/en/class.mongodb-driver-readpreference.php>`__
236+
- `MongoDB\\Driver\\ReadPreference <https://www.php.net/manual/en/class.mongodb-driver-readpreference.php>`__
227237
- | **MongoDB\Client**: ``$uriOptions = [ 'readPreference' => MongoDB\Driver\ReadPreference.RP_SECONDARY_PREFERRED ];``
228238
| **Connection URI**: ``readPreference=secondaryPreferred``
229239

@@ -237,13 +247,13 @@ Read Preference Options
237247
- | **MongoDB\Client**: ``$uriOptions = [ 'readPreferenceTags' => [[ 'region' => 'east' ], [ 'region' => 'west']];``
238248
| **Connection URI**: ``readPreferenceTags=region:east,region:west``
239249

240-
241250
Authentication Options
242251
~~~~~~~~~~~~~~~~~~~~~~
243252

244253
.. list-table::
245254
:header-rows: 1
246255
:stub-columns: 1
256+
:widths: 20 10 70
247257

248258
* - Connection Option
249259
- Data Type
@@ -343,4 +353,4 @@ For more information about the types used on this page, see the following API
343353
documentation:
344354

345355
- :ref:`MongoDB\Client <php-mongodbclient>`
346-
- `MongoDB\Driver\ReadPreference <https://www.php.net/manual/en/class.mongodb-driver-readpreference.php>`__
356+
- `MongoDB\\Driver\\ReadPreference <https://www.php.net/manual/en/class.mongodb-driver-readpreference.php>`__

source/includes/connect/connection-options.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,26 @@
22
<?php
33

44
// Replace the placeholders with your actual hostname, port, and path to the certificate key file
5-
$uri = "mongodb://<hostname>:<port>/?tls=true&tlsCertificateKeyFile=path/to/file.pem";
5+
$uri = "mongodb://<hostname>:<port>/?tls=true&tlsCertificateKeyFile=/path/to/file.pem";
66

77
// Create a MongoDB client
88
$client = new MongoDB\Client($uri);
99
// end-connection-uri
1010

1111
// start-client-options
12-
#include <mongocxx/uri.hpp>
13-
#include <mongocxx/client.hpp>
14-
#include <mongocxx/instance.hpp>
12+
<?php
1513

16-
int main()
17-
{
18-
mongocxx::instance instance;
19-
mongocxx::options::client client_options;
20-
mongocxx::options::tls tls_options;
14+
// Replace the placeholders with your actual hostname and port
15+
$uri = "mongodb://<hostname>:<port>/";
2116

22-
tls_options.pem_file("/path/to/file.pem");
23-
client_options.tls_opts(tls_options);
17+
// Set the connection options
18+
$uriOptions = [
19+
'tls' => true,
20+
'tlsCertificateKeyFile' => '/path/to/file.pem'
21+
];
2422

25-
mongocxx::uri uri("mongodb://<hostname>:<port>/?tls=true");
26-
mongocxx::client client(uri, client_options);
27-
}
23+
// Create a MongoDB client with the URI and options
24+
$client = new Client($uri, $uriOptions);
2825
// end-client-options
2926

3027
// start-uri-object

0 commit comments

Comments
 (0)