Skip to content

DOCSP-51123: CC edits and cleanup #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "mongodb/docs-php-library",
"description": "MongoDB PHP Library Documentation",
"require": {
"ext-mongodb": "^1.20",
"mongodb/mongodb": "^1.20"
"ext-mongodb": "^2.1",
"mongodb/mongodb": "^2.1"
},
"require-dev": {
"doctrine/coding-standard": "^12.0",
Expand All @@ -15,4 +15,4 @@
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
}
7 changes: 0 additions & 7 deletions source/aggregation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,6 @@ learn more, see the :ref:`php-atlas-search` guide.
You can perform similarity searches on vector embeddings by using the
Atlas Vector Search feature. To learn more, see the :ref:`php-vector-search` guide.

.. TODO:
Aggregation Tutorials
~~~~~~~~~~~~~~~~~~~~~

.. To view step-by-step explanations of common aggregation tasks, see
.. :ref:`php-aggregation-tutorials-landing`.

API Documentation
~~~~~~~~~~~~~~~~~

Expand Down
273 changes: 16 additions & 257 deletions source/connect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,247 +132,25 @@ The following code shows how to connect to a replica set deployment:
To learn more about connecting to a replica set, see :ref:`php-connection-replica-set`
in the Connection Targets guide.

Transport Layer Security (TLS)
------------------------------

Enable TLS
~~~~~~~~~~

The following code shows how to enable TLS for the connection to your
MongoDB instance:

.. tabs::

.. tab:: MongoDB\\Client
:tabid: Client

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-enable-tls-client
:end-before: end-enable-tls-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-enable-tls-uri
:end-before: end-enable-tls-uri

To learn more about enabling TLS, see :ref:`php-enable-tls` in
the TLS Configuration guide.

Specify a Certificate Authority (CA) File
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following code shows how to specify the path to your CA file
for the connection to your MongoDB instance:

.. tabs::

.. tab:: MongoDB\\Client
:tabid: Client

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-ca-file-client
:end-before: end-ca-file-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-ca-file-uri
:end-before: end-ca-file-uri

To learn more about specifying a CA file, see :ref:`php-specify-ca-file` in
the TLS Configuration guide.

Disable OCSP Checks
~~~~~~~~~~~~~~~~~~~

The following code shows how to prevent the driver from contacting
the OCSP endpoint:

.. tabs::

.. tab:: MongoDB\\Client
:tabid: Client

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-disable-ocsp-client
:end-before: end-disable-ocsp-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-disable-ocsp-uri
:end-before: end-disable-ocsp-uri

To learn more about disabling OCSP checks, see :ref:`php-disable-ocsp` in
the TLS Configuration guide.

Specify a Certificate Revocation List (CRL)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{+stable-api+}
--------------

The following code shows how to instruct the driver to verify the server's
certificate against a CRL:
The following code shows how to enable the {+stable-api+} for the
connection to your MongoDB instance:

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-crl
:end-before: end-crl

To learn more about specifying a CRL, see :ref:`php-crl` in the TLS
configuration guide.

Present a Client Certificate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following code shows how to specify the client certificate that
the driver presents to your MongoDB deployment:

.. tabs::

.. tab:: MongoDB\\Client
:tabid: Client

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-client-cert-client
:end-before: end-client-cert-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-client-cert-uri
:end-before: end-client-cert-uri

To learn more about specifying a client certificate, see :ref:`php-client-cert` in
the TLS Configuration guide.

Provide a Certificate Key File Password
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following code shows how to specify the password for your
client certificate:

.. tabs::

.. tab:: MongoDB\\Client
:tabid: Client

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-key-file-client
:end-before: end-key-file-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-key-file-uri
:end-before: end-key-file-uri

.. important::

When replacing the ``<password>`` placeholder in the connection URI, ensure
that you :wikipedia:`percent-encode <Percent-encoding>` the value.

To learn more about providing a key file password, see :ref:`php-key-file-password` in
the TLS Configuration guide.

Allow Insecure TLS
~~~~~~~~~~~~~~~~~~

The following code shows how to relax TLS constraints, which has the same
effect as disabling both :ref:`certificate validation <php-connect-disable-cert>`
and :ref:`hostname verification <php-connect-disable-hostname>`:

.. tabs::

.. tab:: MongoDB\\Client
:tabid: Client

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-insecure-tls-client
:end-before: end-insecure-tls-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-insecure-tls-uri
:end-before: end-insecure-tls-uri

To learn more about allowing insecure TLS, see :ref:`php-insecure-tls` in
the TLS Configuration guide.

.. warning::

Setting the ``tlsInsecure`` option to ``true`` might expose your application
to security risks. Enabling this option makes your application insecure and
potentially vulnerable to expired certificates and to foreign processes posing
as valid client instances.

.. _php-connect-disable-cert:

Disable Certificate Validation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following code shows how to disable certificate validation:

.. tabs::

.. tab:: MongoDB\\Client
:tabid: Client

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-disable-cert-client
:end-before: end-disable-cert-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-disable-cert-uri
:end-before: end-disable-cert-uri

To learn more about disabling certificate validation, see :ref:`php-insecure-tls` in
the TLS Configuration guide.
:start-after: start-stable-api
:end-before: end-stable-api

.. _php-connect-disable-hostname:
To learn more about the {+stable-api+}, see the :ref:`php-stable-api` guide.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: out of scope of this PR but should all of the TLS content go in its own page in the specify options drawer? I have seen this TOC org in other drivers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put TLS in the Security drawer based on the unified toc spreadsheet. But I should move this content anyway (to the Security landing page)


Disable Hostname Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Network Compression
-------------------

The following code shows how to disable hostname verification:
The following code shows how to specify the Snappy, Zlib, and Zstandard
compression algorithms for a connection:

.. tabs::

Expand All @@ -382,35 +160,16 @@ The following code shows how to disable hostname verification:
.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-disable-hostname-client
:end-before: end-disable-hostname-client
:start-after: start-compression-client
:end-before: end-compression-client

.. tab:: Connection URI
:tabid: connectionstring

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-disable-hostname-uri
:end-before: end-disable-hostname-uri

To learn more about disabling hostname verification, see :ref:`php-insecure-tls` in
the TLS Configuration guide.

{+stable-api+}
--------------

The following code shows how to enable the {+stable-api+} for the
connection to your MongoDB instance:

.. literalinclude:: /includes/usage-examples/connect-code-examples.php
:language: php
:dedent:
:start-after: start-stable-api
:end-before: end-stable-api

To learn more about the {+stable-api+}, see the :ref:`php-stable-api` guide.
:start-after: start-compression-uri
:end-before: end-compression-uri

.. TODO:
Network Compression
-------------------
To learn more about network compression, see the :ref:`php-network-compression` guide.
Loading
Loading