-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35938: Connection Guide docs #2881
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
DOCSP-35938: Connection Guide docs #2881
Conversation
|
||
- ``maxPoolSize=20`` | ||
- ``w=majority`` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note:
This section will include a link to the Connection Options page once completed.
|
||
.. code-block:: bash | ||
|
||
DB_URI="mongodb://myUser:myPass123@host1:27017,host2:27017,host3:27017/?replicaSet=myRS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After testing on a local replica set, I can confirm that the replicatSet
option works.
MONGODB_URI="mongodb://localhost:27017,localhost:27018,localhost:27019/"
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGODB_URI'),
'database' => 'laravel',
'options' => [
'replicaSet' => 'myRS',
]
]
You can also pass the list of hosts like this:
'mongodb' => [
'driver' => 'mongodb',
'host' => [
'127.0.0.1:27017',
'127.0.0.1:27018',
'127.0.0.1:27019',
],
'database' => 'laravel',
'options' => [
'replicaSet' => 'myRS',
]
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few things!
docs/fundamentals.txt
Outdated
/fundamentals/database-collection | ||
/fundamentals/read-operations | ||
/fundamentals/write-operations | ||
|
||
Learn how to use the {+odm-long+} to perform the following tasks: | ||
|
||
- :ref:`Manage Databases and Collections <laravel-db-coll>` | ||
- :ref:`Connections <laravel-fundamentals-connection>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: though Connections is the name of the page, perhaps this link text could be more matched to the intro phrase "perform the following tasks"
- :ref:`Connections <laravel-fundamentals-connection>` | |
- :ref:`Configure Your Connection to MongoDB <laravel-fundamentals-connection>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add an item to the cleanup ticket to address the other titles that aren't action oriented.
docs/fundamentals.txt
Outdated
/fundamentals/database-collection | ||
/fundamentals/read-operations | ||
/fundamentals/write-operations | ||
|
||
Learn how to use the {+odm-long+} to perform the following tasks: | ||
|
||
- :ref:`Manage Databases and Collections <laravel-db-coll>` | ||
- :ref:`Connections <laravel-fundamentals-connection>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: also add this to the list of fundamentals pages on the index (alternatively, move into an include that is used on both pages)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the item to index.txt and then adding the task to move it into an include to the cleanup ticket since it impacts other content.
docs/fundamentals/connection.txt
Outdated
Learn how to set up a connection and specify connection behavior from your | ||
Laravel application to a MongoDB deployment by using {+odm-short+} in the | ||
following sections: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Learn how to set up a connection and specify connection behavior from your | |
Laravel application to a MongoDB deployment by using {+odm-short+} in the | |
following sections: | |
Learn how to set up a connection from your Laravel application to a MongoDB | |
deployment and specify connection behavior by using {+odm-short+} in the | |
following sections: |
docs/fundamentals/connection.txt
Outdated
Laravel application to a MongoDB deployment by using {+odm-short+} in the | ||
following sections: | ||
|
||
- :ref:`Connect to MongoDB <laravel-connect-to-mongodb>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: why is this called connect to MongoDB instead of Connection Guide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a custom title with similar intent to the suggestions you made earlier. To keep it simple, I'd suggest that we only use the titles of the pages and then describe them as necessary. Let me know what you think and I'll add the appropriate task to the cleanup ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like a good solution to prevent the same page from being referred to by different things in different places!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, added "Use the original titles for all landing page link lists. Use a description if it needs additional explanation." to the cleanup ticket.
- ``default``, which specifies the default database connection to use when | ||
unspecified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ``default``, which specifies the default database connection to use when | |
unspecified | |
- ``default``, which specifies the default database connection to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I wanted to emphasize the behavior of the default value, but now think maybe including "default" in the description of itself might be confusing. think maybe a more clear way to describe this could be:
"default, which specifies the database connection to use when unspecified"
- ``driver``, which specifies the database driver to use for the connection | ||
- ``dsn``, the data source name (DSN) that specifies the MongoDB connection URI | ||
- ``host``, which you can use instead of the ``dsn`` setting to specify the | ||
network address of one or more MongoDB nodes | ||
- ``database``, which specifies the name of the MongoDB database to read and | ||
write to | ||
- ``username`` and ``password``, which you can optionally include to specify | ||
your database user's credentials to authenticate with MongoDB | ||
- ``options`` and ``driverOptions``, which specify connection options to | ||
pass to the MongoDB driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: maybe converting this into a table could be helpful
- ``options`` and ``driverOptions``, which specify connection options to | ||
pass to the MongoDB driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: is there a place to find a complete list of what goes under each property? Or will this be covered in the connection options page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for asking. These are covered in the Connection Options ticket and a link will be added to this page per #2881 (comment)
To connect your application to a MongoDB instance hosted on the same machine, | ||
you must complete the following tasks: | ||
|
||
- Download, install, and run MongoDB server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Download, install, and run MongoDB server. | |
- Download, install, and run the MongoDB server. |
- ``username`` and ``password``, which you can optionally include to specify | ||
your database user's credentials to authenticate with MongoDB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I: right now, it's not very clear that using different properties such as host username password port, etc. is an alternative to including all of this information in the DSN
S: add an admonition or revise these descriptions to make this clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Will add an admonition to explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
docs/fundamentals/connection.txt
Outdated
Laravel application to a MongoDB deployment by using {+odm-short+} in the | ||
following sections: | ||
|
||
- :ref:`Connect to MongoDB <laravel-connect-to-mongodb>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like a good solution to prevent the same page from being referred to by different things in different places!
one or more databases from your application | ||
|
||
You can use the following code in the configuration file to set the default | ||
connection to a corresponding ``"mongodb"`` entry in the ``connections`` array: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connection to a corresponding ``"mongodb"`` entry in the ``connections`` array: | |
connection to a corresponding ``mongodb`` entry in the ``connections`` array: |
.. code-block:: php | ||
:caption: Sample .env environment configuration | ||
|
||
DB_URI=""mongodb+srv://myUser:[email protected]/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DB_URI=""mongodb+srv://myUser:[email protected]/"; | |
DB_URI="mongodb+srv://myUser:[email protected]/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, great catch!
I should also use "bash" instead of "php" highlighting.
* - ``host`` | ||
- Specifies the network address of one or more MongoDB nodes in a | ||
deployment. You can use this setting instead of the ``dsn`` setting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is host:port
or a list of host:port
.
Examples:
'host' => 'localhost:27017'
'host' => ['server1.example.net:27017', 'server2.example.net:27017', 'server3.example.net:27017']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: from my experimentation, this option only accepts non-seedlist hostnames (mongodb
and not mongodb+srv
), correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, we need to add an option for mongodb+srv
.
laravel-mongodb/src/Connection.php
Line 255 in d0978a8
return 'mongodb://' . implode(',', $hosts) . ($authDatabase ? '/' . $authDatabase : ''); |
* - ``options`` | ||
- Specifies connection options to pass to MongoDB that determine the | ||
connection behavior. | ||
|
||
* - ``driverOptions`` | ||
- Specifies options specific to pass to the MongoDB PHP Library driver | ||
that determine the driver behavior for that connection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should link to the doc of options: https://www.mongodb.com/docs/php-library/current/reference/method/MongoDBClient__construct/#parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will add links from options and driverOptions to the Connection Options page (which includes the link you provided) once merged as a cleanup task.
JIRA: https://jira.mongodb.org/browse/DOCSP-35938
Staging:
Connection Guide
Checklist