-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35892: Quick Start docs #2721
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
Changes from 17 commits
0f3d840
4577038
47fdb6c
78f6fe3
89f5a25
f4487c9
0126d53
dcf330f
d6397cb
ffcc0a5
d6f7dc5
d6e9043
c7c93c7
07b3c8d
63037d3
c913056
38b94c2
96b5a8a
52d3136
da6b2b0
3663a0c
650317c
6c5b1f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.. note:: | ||
|
||
If you run into issues on this step, ask for help in the | ||
:community-forum:`MongoDB Community Forums <>` or submit feedback by using | ||
the :guilabel:`Share Feedback` tab on the right or bottom right side of the | ||
page. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.. _laravel-quick-start: | ||
|
||
=========== | ||
Quick Start | ||
=========== | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: tutorial | ||
|
||
.. meta:: | ||
:keywords: php framework, odm | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
:class: singlecol | ||
|
||
Overview | ||
-------- | ||
|
||
This guide shows you how to add {+odm-long+} to a new Laravel web application, | ||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
connect to a MongoDB cluster hosted on MongoDB Atlas, and how to perform | ||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
read and write operations on the data. | ||
|
||
.. tip:: | ||
|
||
If you prefer to set up your development environment in GitHub Codespaces | ||
or Docker, see the linked code repository in the | ||
`How to Build a Laravel + MongoDB Back End Service <https://www.mongodb.com/developer/languages/php/laravel-mongodb-tutorial/>`__ | ||
MongoDB Developer Center tutorial. | ||
|
||
You can learn how to set up a local Laravel development environment | ||
and perform CRUD operations by taking the | ||
:mdbu-course:`Getting Started with Laravel and MongoDB </getting-started-with-laravel-and-mongodb>` | ||
MongoDB University Learning Byte. | ||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If you prefer to connect to MongoDB by using the PHP Library driver without | ||
Laravel, see `Connecting to MongoDB <https://www.mongodb.com/docs/php-library/current/tutorial/connecting/>`__ | ||
in the PHP Library documentation. | ||
|
||
{+odm-short+} extends the Laravel Eloquent and Query Builder syntax to | ||
store and retrieve data from MongoDB. | ||
|
||
MongoDB Atlas is a fully managed cloud database service that hosts your | ||
MongoDB deployments. You can create your own free (no credit card | ||
required) MongoDB Atlas deployment by following the steps in this guide. | ||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Follow the steps in this guide to create a sample Laravel web application | ||
that connects to a MongoDB deployment. | ||
|
||
.. tip:: | ||
|
||
You can download the complete web application project by cloning the | ||
`laravel-quickstart <https://github.com/mongodb-university/laravel-quickstart>`__ | ||
GitHub repository. | ||
|
||
.. button:: Next: Download and Install | ||
:uri: /quick-start/download-and-install/ | ||
|
||
.. toctree:: | ||
|
||
/quick-start/download-and-install/ | ||
/quick-start/create-a-deployment/ | ||
/quick-start/create-a-connection-string/ | ||
/quick-start/configure-mongodb/ | ||
/quick-start/view-data/ | ||
/quick-start/write-data/ | ||
/quick-start/next-steps/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.. _laravel-quick-start-connect-to-mongodb: | ||
|
||
================================= | ||
Configure Your MongoDB Connection | ||
================================= | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: tutorial | ||
|
||
.. meta:: | ||
:keywords: test connection, runnable, code example | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Set the Connection String in the Database Configuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I: per the style guide, I think these steps should use sentence-style capitalization There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applies to the other steps/files too |
||
|
||
Open the ``database.php`` file in the ``config`` directory and | ||
set the default database connection to ``mongodb`` as shown | ||
in the following line: | ||
|
||
.. code-block:: php | ||
|
||
'default' => env('DB_CONNECTION', 'mongodb'), | ||
|
||
Add the following highlighted ``mongodb`` entry to the ``connections`` array | ||
in the same file. Replace the ``<connection string>`` placeholder with the | ||
connection string that you copied from the :ref:`laravel-quick-start-connection-string` | ||
step in the following code example: | ||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. code-block:: php | ||
:emphasize-lines: 2-6 | ||
|
||
'connections' => [ | ||
'mongodb' => [ | ||
'driver' => 'mongodb', | ||
'dsn' => env('DB_URI', '<connection string>'), | ||
'database' => 'sample_mflix', | ||
], | ||
|
||
// ... | ||
|
||
.. step:: Add the Laravel MongoDB Provider | ||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Open the ``app.php`` in the ``config`` directory and | ||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
add the following entry into the ``providers`` array: | ||
|
||
.. code-block:: | ||
|
||
MongoDB\Laravel\MongoDBServiceProvider::class, | ||
|
||
.. include:: /includes/quick-start/troubleshoot.rst | ||
|
||
.. button:: Next: View Sample MongoDB Data | ||
:uri: /quick-start/view-data/ |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,63 @@ | ||||||||||||||||||
.. _laravel-quick-start-connection-string: | ||||||||||||||||||
|
||||||||||||||||||
========================== | ||||||||||||||||||
Create a Connection String | ||||||||||||||||||
========================== | ||||||||||||||||||
|
||||||||||||||||||
You can connect to your MongoDB deployment by providing a | ||||||||||||||||||
**connection URI**, also called a *connection string*, which | ||||||||||||||||||
instructs the driver on how to connect to a MongoDB deployment | ||||||||||||||||||
and how to behave while connected. | ||||||||||||||||||
|
||||||||||||||||||
The connection string includes the hostname or IP address and | ||||||||||||||||||
port of your deployment, the authentication mechanism, user credentials | ||||||||||||||||||
when applicable, and connection options. | ||||||||||||||||||
|
||||||||||||||||||
To connect to an instance or deployment not hosted on Atlas, see the | ||||||||||||||||||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
:manual:`Connection Strings </reference/connection-string/>` in the Server | ||||||||||||||||||
manual. | ||||||||||||||||||
|
||||||||||||||||||
.. procedure:: | ||||||||||||||||||
:style: connected | ||||||||||||||||||
|
||||||||||||||||||
.. step:: Find your MongoDB Atlas Connection String | ||||||||||||||||||
|
||||||||||||||||||
To retrieve your connection string for the deployment that | ||||||||||||||||||
you created in the :ref:`previous step <laravel-quick-start-create-deployment>`, | ||||||||||||||||||
log in to your Atlas account and navigate to the | ||||||||||||||||||
:guilabel:`Database` section and click the :guilabel:`Connect` button | ||||||||||||||||||
for your new deployment. | ||||||||||||||||||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
||||||||||||||||||
.. figure:: /includes/figures/atlas_connection_select_cluster.png | ||||||||||||||||||
:alt: The connect button in the clusters section of the Atlas UI | ||||||||||||||||||
|
||||||||||||||||||
Proceed to the :guilabel:`Connect your application` section and select | ||||||||||||||||||
"PHP" from the :guilabel:`Driver` selection menu and the version | ||||||||||||||||||
that best matches the version you installed from the :guilabel:`Version` | ||||||||||||||||||
selection menu. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S: this sentence is a little long, think it can be broken up
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
Select the :guilabel:`Password (SCRAM)` authentication mechanism. | ||||||||||||||||||
|
||||||||||||||||||
Deselect the :guilabel:`Include full driver code example` to view | ||||||||||||||||||
ccho-mongodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
the connection string. | ||||||||||||||||||
|
||||||||||||||||||
.. step:: Copy your Connection String | ||||||||||||||||||
|
||||||||||||||||||
Click the button on the right of the connection string to copy it | ||||||||||||||||||
to your clipboard. | ||||||||||||||||||
|
||||||||||||||||||
.. step:: Update the Placeholders | ||||||||||||||||||
|
||||||||||||||||||
Paste this connection string into a file in your preferred text editor | ||||||||||||||||||
and replace the ``<username>`` and ``<password>`` placeholders with | ||||||||||||||||||
your database user's username and password. | ||||||||||||||||||
|
||||||||||||||||||
Save this file to a safe location for use in the next step. | ||||||||||||||||||
|
||||||||||||||||||
After completing these steps, you have a connection string that | ||||||||||||||||||
contains your database username and password. | ||||||||||||||||||
|
||||||||||||||||||
.. include:: /includes/quick-start/troubleshoot.rst | ||||||||||||||||||
|
||||||||||||||||||
.. button:: Next: Configure Your MongoDB Connection | ||||||||||||||||||
:uri: /quick-start/configure-mongodb/ |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||||||||||||
.. _laravel-quick-start-create-deployment: | ||||||||||||||||
|
||||||||||||||||
=========================== | ||||||||||||||||
Create a MongoDB Deployment | ||||||||||||||||
=========================== | ||||||||||||||||
|
||||||||||||||||
You can create a free tier MongoDB deployment on MongoDB Atlas | ||||||||||||||||
to store and manage your data. MongoDB Atlas hosts and manages | ||||||||||||||||
your MongoDB database in the cloud. | ||||||||||||||||
|
||||||||||||||||
.. procedure:: | ||||||||||||||||
:style: connected | ||||||||||||||||
|
||||||||||||||||
.. step:: Create a Free MongoDB deployment on Atlas | ||||||||||||||||
|
||||||||||||||||
Complete the :atlas:`Get Started with Atlas </getting-started?tck=docs_driver_laravel>` | ||||||||||||||||
guide to set up a new Atlas account and load sample data into a new free | ||||||||||||||||
tier MongoDB deployment. | ||||||||||||||||
|
||||||||||||||||
.. step:: Save your Credentials | ||||||||||||||||
|
||||||||||||||||
After you create your database user, save that user's | ||||||||||||||||
username and password to a safe location for use in an upcoming step. | ||||||||||||||||
|
||||||||||||||||
After you complete these steps, you have a new free tier MongoDB | ||||||||||||||||
deployment on Atlas, database user credentials, and sample data loaded | ||||||||||||||||
into your database. | ||||||||||||||||
|
||||||||||||||||
.. note:: | ||||||||||||||||
|
||||||||||||||||
If you run into issues on this step, ask for help in the | ||||||||||||||||
:community-forum:`MongoDB Community Forums <>` | ||||||||||||||||
or submit feedback by using the :guilabel:`Share Feedback` | ||||||||||||||||
tab on the right or bottom right side of this page. | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S: replace this note with the troubleshoot.rst file
Suggested change
|
||||||||||||||||
|
||||||||||||||||
.. button:: Next: Create a Connection String | ||||||||||||||||
:uri: /quick-start/create-a-connection-string/ |
Uh oh!
There was an error while loading. Please reload this page.