-
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
Merged
ccho-mongodb
merged 23 commits into
mongodb:4.1
from
ccho-mongodb:DOCSP-35892-quick-start-docs
Feb 8, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0f3d840
DOCSP-35892: quick start docs
4577038
added steps, fixed rst
47fdb6c
add link to the devcenter article
78f6fe3
grammar
89f5a25
download and install content
f4487c9
RST fixes, reformat requirements
0126d53
quick start updates
dcf330f
shorten download and install and other fixes
d6397cb
tweaks
ffcc0a5
fixes
d6f7dc5
rst fixes
d6e9043
fixes
c7c93c7
reworrd intro
07b3c8d
grammar updates
63037d3
Merge branch '4.1' into DOCSP-35892-quick-start-docs
c913056
learning byte
38b94c2
formatting fixes
96b5a8a
PRR fixes
52d3136
more edits
da6b2b0
avoid subjunctive
3663a0c
PRR fixes
650317c
PRR fixes
6c5b1f7
revert .vscode change
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.. note:: | ||
|
||
If you run into issues, 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 contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 the {+odm-long+} to a new Laravel web | ||
application, connect to a MongoDB cluster hosted on MongoDB Atlas, and perform | ||
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 viewing the | ||
:mdbu-course:`Getting Started with Laravel and MongoDB </getting-started-with-laravel-and-mongodb>` | ||
MongoDB University Learning Byte. | ||
|
||
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. | ||
|
||
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/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.. _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 | ||
|
||
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 | ||
|
||
Open the ``app.php`` file in the ``config`` directory and | ||
add the following entry into the ``providers`` array: | ||
|
||
.. code-block:: | ||
|
||
MongoDB\Laravel\MongoDBServiceProvider::class, | ||
|
||
After completing these steps, your Laravel web application is ready to | ||
connect to MongoDB. | ||
|
||
.. include:: /includes/quick-start/troubleshoot.rst | ||
|
||
.. button:: Next: View Sample MongoDB Data | ||
:uri: /quick-start/view-data/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
: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. Then, navigate to the | ||
:guilabel:`Database` section and click the :guilabel:`Connect` button | ||
for your new deployment. | ||
|
||
.. 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. Select | ||
"PHP" from the :guilabel:`Driver` selection menu and the version | ||
that best matches the version you installed from the :guilabel:`Version` | ||
selection menu. | ||
|
||
Select the :guilabel:`Password (SCRAM)` authentication mechanism. | ||
|
||
Deselect the :guilabel:`Include full driver code example` option to view | ||
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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.. _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 completing these steps, you have a new free tier MongoDB deployment on | ||
Atlas, database user credentials, and sample data loaded into your database. | ||
|
||
.. include:: /includes/quick-start/troubleshoot.rst | ||
|
||
.. button:: Next: Create a Connection String | ||
:uri: /quick-start/create-a-connection-string/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.