Skip to content

Commit c02d343

Browse files
committed
Add example for creating new Client with auto encryption
1 parent e78f478 commit c02d343

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/reference/method/MongoDBDatabase-createEncryptedCollection.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ the return value from :phpmethod:`MongoDB\\Database::createCollection()` and
101101
:php:`MongoDB\\BSON\\Binary <class.mongodb-bson-binary>` object with subtype 4
102102
(i.e. UUID).
103103

104+
The modified ``encryptedFields`` option can then be used to construct a new
105+
:phpclass:`MongoDB\\Client` with auto encryption enabled.
106+
107+
.. code-block:: php
108+
109+
<?php
110+
111+
$encryptedClient = new MongoDB\Client(
112+
null, // Connection string
113+
[], // Additional connection string options
114+
[
115+
'autoEncryption' => [
116+
'keyVaultNamespace' => 'keyvault.datakeys',
117+
'kmsProviders' => [
118+
'local' => ['key' => new MongoDB\BSON\Binary(base64_decode(LOCAL_MASTERKEY), 0)],
119+
],
120+
'encryptedFieldsMap' => [
121+
'test.users' => $encryptedFields,
122+
],
123+
],
124+
]
125+
);
126+
104127
See Also
105128
--------
106129

0 commit comments

Comments
 (0)