Skip to content

DOCSP-48860: DOCS+ tutorial - Laravel MongoDB backend #3386

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

Open
wants to merge 5 commits into
base: 5.4
Choose a base branch
from

Conversation

rustagir
Copy link
Contributor

@rustagir rustagir commented May 22, 2025

https://jira.mongodb.org/browse/DOCSP-48860

Moves the How To Build a Laravel + MongoDB Back End Service tutorial into docs.

STAGING

Checklist

  • Add tests and ensure they pass

@github-actions github-actions bot added the docs label May 22, 2025
@rustagir rustagir changed the title DOCSP-48860: DOCS+ tutorial WIP DOCSP-48860: DOCS+ tutorial - Laravel MongoDB backend May 27, 2025
@rustagir rustagir marked this pull request as ready for review May 27, 2025 18:18
@rustagir rustagir requested a review from a team as a code owner May 27, 2025 18:18
@rustagir rustagir requested a review from lindseymoore May 27, 2025 18:18
Copy link
Collaborator

@lindseymoore lindseymoore left a comment

Choose a reason for hiding this comment

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

A few comments for your consideration!

php artisan serve

Navigate to http://127.0.0.1:8000/info to view the PHPinfo page.
Verify that the {+php-extension+} is installed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: Is there a line they should check for in the info page to make sure the PHP extension is installed properly? Could be helpful to include.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add

'connections' => [
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGODB_URI'),
Copy link
Collaborator

@lindseymoore lindseymoore May 28, 2025

Choose a reason for hiding this comment

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

Suggested change
'dsn' => env('MONGODB_URI'),
'dsn' => '<mongodb_uri>',

S: The linked to create a connection string page does not talk about setting the connection string as an environment variable. I would use a generic placeholder here instead to avoid confusion. You can also perhaps include a sentence about saving the uri as an environment variable without explicitly saying how.

``Model`` classes represent rows of tables in relational
databases. In MongoDB, they are documents in the collection.

Your models can define fillable fields if you want to enforce a
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Your models can define fillable fields if you want to enforce a
You can use Eloquent models to define fillable fields if you want to enforce a

S: Just to remain consistent with using the 'Eloquent models' term since 'models' is kind of vague.

the ``embedsMany()`` and ``embedsOne()`` methods.

As shown in the preceding step, you can define top-level schema
attributes. However, it is more complicated when using arrays
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
attributes. However, it is more complicated when using arrays
attributes. However, it is more complicated to define top level schema attributes for arrays

S: For present tense and specificity

.. contents:: On this page
:local:
:backlinks: none
:depth: 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
:depth: 1
:depth: 2

S: To show steps in TOC


In this tutorial, you learned how to create a back-end service by using
Laravel and MongoDB for a front-end web application.
This tutorial also showed why the document model leads to higher
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This tutorial also showed why the document model leads to higher
This tutorial also showed how the document model leads to higher

S: Or 'explained why'

:github:`laravel-mongodb-tutorial
</mongodb-developer/laravel-mongodb-tutorial/>` repository on GitHub.

See the :ref:`laravel_fundamentals` guides to learn more about
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
See the :ref:`laravel_fundamentals` guides to learn more about
See the :ref:`<link to Laravel home page>` guides to learn more about

S: Maybe direct to the Laravel docs home page instead bc it looks nicer?
https://deploy-preview-192--docs-laravel.netlify.app/

Copy link
Collaborator

@lindseymoore lindseymoore left a comment

Choose a reason for hiding this comment

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

LGTM w/ a few comments! Let me know if you want another look :)

'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGODB_URI'),
'database' => '<database name>',
Copy link
Collaborator

@lindseymoore lindseymoore May 30, 2025

Choose a reason for hiding this comment

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

I think a placeholder would make more sense, so there is no doubt that the user has to replace the database name. But I'll leave it up to you!

Comment on lines +103 to +104
in the preceding code or set the ``MONGODB_URI`` environment variable to
your connection string before you run your application. To learn
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
in the preceding code or set the ``MONGODB_URI`` environment variable to
your connection string before you run your application. To learn
in the preceding code or set the ``MONGODB_URI`` environment variable to
your connection string and remove the placeholder before you run your application. To learn

S: Just because the code won't work as intended if you leave the placeholder if I'm understanding correctly.

]);
});

After inserting the document, you can retrieve it by using the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
After inserting the document, you can retrieve it by using the
After you insert the document, you can retrieve it by using the

S: present tense


MongoDB provides the Query API for optimized queries.

You can begin building a query from a ``collection`` object.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
You can begin building a query from a ``collection`` object.
You can build a query by using a ``collection`` object.

S: present tense, simplicity

$result->getDeletedCount() ];
});

To learn more about performing CRUD operations, see the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
To learn more about performing CRUD operations, see the
To learn more about how to perform CRUD operations, see the

S: present tense

.. step:: Use indexes to optimize query performance.

You can create indexes to support your queries and improve
performance. To learn more about creating indexes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
performance. To learn more about creating indexes
performance. To learn more about how to create indexes

S: present tense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants