Skip to content

DOCSP-43396: Cleanup #151

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 18 commits into from
Sep 27, 2024
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
2 changes: 1 addition & 1 deletion snooty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ php-library = "MongoDB PHP Library"

[constants]
php-library = "MongoDB PHP Library"
driver-short = "PHP library"
Copy link
Collaborator

Choose a reason for hiding this comment

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

S: I might have suggested removing this in the past, but I think it is actually good to have in here, even as a repeat. There are some sharedincludes that we might use that might use this source constant. Maybe you can just do this:
driver-short = "{+library-short+}"

extension-short = "PHP extension"
mdb-server = "MongoDB Server"
stable-api = "Stable API"
library-short = "PHP library"
driver-short = "{+library-short+}"
api = "https://www.mongodb.com/docs/php-library/current/reference"
php-manual = "https://www.php.net/manual/en"
string-data-type = "``string``"
Expand Down
4 changes: 2 additions & 2 deletions source/aggregation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,5 @@ API Documentation
To learn more about the methods discussed in this guide, see the
following API documentation:

- `MongoDB\\Collection::aggregate() <{+api+}/method/MongoDBCollection-aggregate/>`__
- `MongoDB\\Collection::explain() <{+api+}/method/MongoDBCollection-explain/>`__
- :phpmethod:`MongoDB\Collection::aggregate()`
- :phpmethod:`MongoDB\Collection::explain()`
2 changes: 1 addition & 1 deletion source/connect/client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ API Documentation
To learn more about creating a ``MongoDB\Client`` object in the {+library-short+},
see the following API documentation:

- :ref:`MongoDB\Client <php-api-mongodbclient>`
- :phpclass:`MongoDB\Client`
2 changes: 1 addition & 1 deletion source/connect/connection-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ entry in the {+mdb-server+} manual.
To learn more, see the following resources:

- `RFC 3986 <http://www.faqs.org/rfcs/rfc3986.html>`__
- `rawurlencode <{+php-manual+}/rawurlencode>`__ in the PHP manual
- :php:`rawurlencode <rawurlencode>` in the PHP manual

Replica Set Options
~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion source/connect/connection-targets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ API Documentation
To learn more about using the ``MongoDB\Client`` class,
see the following API documentation:

- :ref:`MongoDB\Client <php-api-mongodbclient>`
- :phpclass:`MongoDB\Client`
2 changes: 1 addition & 1 deletion source/connect/stable-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The following code example shows how you can use these parameters when construct
API Documentation
-----------------

For more information about the ``MongoDB\Client`` class, see the following {+driver-short+}
For more information about the ``MongoDB\Client`` class, see the following {+library-short+}
API documentation:

- :phpclass:`MongoDB\Client`
Expand Down
4 changes: 2 additions & 2 deletions source/databases-collections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ the ``test_database`` database:

To learn more about ``__get()`` and PHP magic methods, see the following resources:

- :phpmethod:`MongoDB\Client::__get()` in the API documentation
- `Magic Methods <{+php-manual+}/language.oop5.magic.php>`__ in the PHP manual
- :phpmethod:`MongoDB\Client::__get()` in the library API documentation
- :php:`Magic Methods <language.oop5.magic>` in the PHP manual

.. _php-db-coll-access-collection:

Expand Down
29 changes: 23 additions & 6 deletions source/get-started/connect-to-mongodb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,26 @@ the Atlas sample datasets.

.. step:: Assign the connection string

Replace the ``<connection string>`` placeholder with the
connection string that you copied from the :ref:`php-connection-string`
step of this guide.
Assign the ``MONGODB_URI`` environment variable to the connection string that you copied
from the :ref:`php-connection-string` step of this guide. You can assign this
variable by running a shell command or creating a ``.env`` file in your application,
as show in the following tabs:

.. tabs::

.. tab:: Shell Command
:tabid: shell

.. code-block:: sh

export MONGODB_URI=<connection string>

.. tab:: .env File
:tabid: dotenv

.. code-block:: none

MONGODB_URI=<connection string>

.. step:: Run your PHP application

Expand All @@ -58,9 +75,9 @@ the Atlas sample datasets.
...
}

If you encounter an error or see no output, ensure that you specified the
proper connection string in the ``quickstart.php`` file and that you loaded the
sample data.
If you encounter an error or see no output, ensure that you assigned the
proper connection string to the ``MONGODB_URI`` environment variable and
that you loaded the sample data.

After you complete these steps, you have a PHP application that
connects to your MongoDB deployment, runs a query on the sample
Expand Down
9 changes: 5 additions & 4 deletions source/get-started/next-steps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ In this tutorial, you created a PHP application that
connects to a MongoDB deployment hosted on MongoDB Atlas
and retrieves a document that matches a query.

.. TODO:
Learn more about the {+php-library+} from the following resources:
- Learn how to perform read operations in the :ref:`<php-read>` section.
- Learn how to perform write operations in the :ref:`<php-write>` section.

Learn more about the {+php-library+} from the following resources:

- Learn how to perform read operations in the :ref:`<php-read>` section.
- Learn how to perform write operations in the :ref:`<php-write>` section.
4 changes: 2 additions & 2 deletions source/includes/aggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$cursor = $collection->aggregate($pipeline);

foreach ($cursor as $doc) {
echo json_encode($doc) , PHP_EOL;
echo json_encode($doc), PHP_EOL;
}
// end-match-group

Expand All @@ -35,6 +35,6 @@
);

$result = $collection->explain($aggregate);
echo json_encode($result) , PHP_EOL;
echo json_encode($result), PHP_EOL;
// end-explain

7 changes: 3 additions & 4 deletions source/includes/connect/atlas.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// Replace the placeholder with your Atlas connection string
$uri = "<connection string>";
$uri = '<connection string>';

// Create a MongoDB client with server API options
$client = new MongoDB\Client($uri, [], [
Expand All @@ -13,7 +13,6 @@
$command = new MongoDB\Driver\Command(['ping' => 1]);
$result = $admin->command($command)->toArray();

echo json_encode($result), "\n";
echo "Pinged your deployment. You successfully connected to MongoDB!\n";
echo json_encode($result), PHP_EOL;
echo 'Pinged your deployment. You successfully connected to MongoDB!\n';

?>
2 changes: 1 addition & 1 deletion source/includes/connect/ca-dir.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$uriOptions = [
'tls' => true,
Expand Down
4 changes: 2 additions & 2 deletions source/includes/connect/ca-file-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -19,5 +19,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsCAFile=/path/to/ca.pem";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsCAFile=/path/to/ca.pem';
$client = MongoDB\Client($uri);
4 changes: 2 additions & 2 deletions source/includes/connect/client-cert-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -19,5 +19,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsCertificateKeyFile=/path/to/client.pem";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsCertificateKeyFile=/path/to/client.pem';
$client = MongoDB\Client($uri);
2 changes: 1 addition & 1 deletion source/includes/connect/crl-file.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$uriOptions = [
'tls' => true,
Expand Down
4 changes: 2 additions & 2 deletions source/includes/connect/crl-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -19,5 +19,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsCRLFile=/path/to/crl.pem";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsCRLFile=/path/to/crl.pem';
$client = MongoDB\Client($uri);
2 changes: 1 addition & 1 deletion source/includes/connect/direct-connection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// Replace the placeholders with your actual hostname and port
$uri = "mongodb://<hostname>:<port>/?directConnection=true";
$uri = 'mongodb://<hostname>:<port>/?directConnection=true';

// Create a MongoDB client
$client = new MongoDB\Client($uri);
4 changes: 2 additions & 2 deletions source/includes/connect/disable-cert-validation-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -19,5 +19,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsAllowInvalidCertificates=true";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsAllowInvalidCertificates=true';
$client = MongoDB\Client($uri);
4 changes: 2 additions & 2 deletions source/includes/connect/disable-host-verification-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -19,5 +19,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsAllowInvalidHostnames=true";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsAllowInvalidHostnames=true';
$client = MongoDB\Client($uri);
4 changes: 2 additions & 2 deletions source/includes/connect/insecure-tls-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -19,5 +19,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsInsecure=true";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsInsecure=true';
$client = MongoDB\Client($uri);
4 changes: 2 additions & 2 deletions source/includes/connect/key-file-password.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -20,5 +20,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsCertificateKeyFile=/path/to/client.pem&tlsCertificateKeyFilePassword=<passphrase>";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsCertificateKeyFile=/path/to/client.pem&tlsCertificateKeyFilePassword=<passphrase>';
$client = MongoDB\Client($uri);
4 changes: 2 additions & 2 deletions source/includes/connect/ocsp-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true,
Expand All @@ -19,5 +19,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true&tlsDisableOCSPEndpointCheck=true";
$uri = 'mongodb://<hostname>:<port>/?tls=true&tlsDisableOCSPEndpointCheck=true';
$client = MongoDB\Client($uri);
2 changes: 1 addition & 1 deletion source/includes/connect/replica-set.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$uri = "mongodb://host1:27017/?replicaSet=sampleRS";
$uri = 'mongodb://host1:27017/?replicaSet=sampleRS';

// Create a MongoDB client
$client = new MongoDB\Client($uri);
4 changes: 2 additions & 2 deletions source/includes/connect/tls-tabs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>";
$uri = 'mongodb://<hostname>:<port>';

$options = [
'tls' => true
Expand All @@ -18,5 +18,5 @@

.. code-block:: php

$uri = "mongodb://<hostname>:<port>/?tls=true";
$uri = 'mongodb://<hostname>:<port>/?tls=true';
$client = MongoDB\Client($uri);
2 changes: 1 addition & 1 deletion source/includes/extracts-bucket-option.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ref: bucket-option-codec
content: |
The :doc:`codec </tutorial/codecs>` to use for encoding or decoding documents.
The :doc:`codec </data-formats/codecs>` to use for encoding or decoding documents.
This option is mutually exclusive with the ``typeMap`` option.

Defaults to the bucket's codec. Inheritance for a default ``codec`` option
Expand Down
2 changes: 1 addition & 1 deletion source/includes/extracts-collection-option.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ref: collection-option-codec
content: |
The :doc:`codec </tutorial/codecs>` to use for encoding or decoding documents.
The :doc:`codec </data-formats/codecs>` to use for encoding or decoding documents.
This option is mutually exclusive with the ``typeMap`` option.

Defaults to the collection's codec. Inheritance for a default ``codec`` option
Expand Down
2 changes: 1 addition & 1 deletion source/includes/extracts-common-option.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ref: common-option-codec
content: |
The :doc:`codec </tutorial/codecs>` to use for encoding or decoding documents.
The :doc:`codec </data-formats/codecs>` to use for encoding or decoding documents.
This option is mutually exclusive with the ``typeMap`` option.
---
ref: common-option-collation
Expand Down
7 changes: 5 additions & 2 deletions source/includes/get-started/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use MongoDB\Client;

$client = new Client('<connection string>');
$uri = getenv('MONGODB_URI') ?: throw new RuntimeException(
'Set the MONGODB_URI environment variable to your Atlas URI'
);
$client = new MongoDB\Client($uri);
$collection = $client->sample_mflix->movies;

$filter = ['title' => 'The Shawshank Redemption'];
Expand All @@ -13,5 +16,5 @@
if ($result) {
echo json_encode($result, JSON_PRETTY_PRINT);
} else {
echo "Document not found";
echo 'Document not found';
}
2 changes: 1 addition & 1 deletion source/includes/indexes/indexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
['title' => ['$regex' => 'Sunrise'],
'year' => ['$gte' => 1990]]
);
echo json_encode($document) , PHP_EOL;
echo json_encode($document), PHP_EOL;
// end-compound-query

// start-multikey
Expand Down
Loading
Loading