Skip to content
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-39180: Symfony Quick Start #971

Merged
merged 27 commits into from
Jun 11, 2024

Conversation

rustagir
Copy link
Contributor

@rustagir rustagir commented May 24, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-39180
Staging - https://preview-mongodbrustagir.gatsbyjs.io/drivers/DOCS-39180-symfony-qs/php-frameworks/symfony/

Self-Review Checklist

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?
  • Are the facets and meta keywords accurate?

@bisht2050
Copy link

bisht2050 commented May 27, 2024

High level, we want to have a page for Symfony where quick start is one of the sections. I envision the page structure to look something like:

  • Overview
  • Intro to Symfony, how Symfony works well with MongoDB using Doctrine ODM etc.
  • Why use MongoDB and Symfony
  • Quick Start
  • Resources (You already have these as Next Steps)

We should also rename the page title (Symfony MongoDB Integration ?) since Quick start is just meant to be a section in it.

source/motor.txt Show resolved Hide resolved
MongoDB deployments. You can create your own free (no credit card
required) MongoDB Atlas deployment by following the steps in this guide.

This guide uses **MongoDB Doctrine ODM**, which is an Object-Document

Choose a reason for hiding this comment

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

MongoDB Doctrine ODM should hyperlink to https://github.com/doctrine/mongodb-odm

source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
<https://mongodb-developer.github.io/symfony-mongodb-rental-workshop/>`__
- `Symfony Documentation <https://symfony.com/doc/current/index.html>`__
- `Doctrine ODM Documentation
<https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/index.html>`__

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

One more which I missed earlier - https://github.com/doctrine/DoctrineMongoDBBundle

Copy link
Member

Choose a reason for hiding this comment

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

I would suggest reducing the ODM links to the following:

I don't think it's worth linking the individual GitHub repositories (note you aren't doing so for Symfony), as that just distracts from the documentation.

Copy link
Contributor

@norareidy norareidy left a comment

Choose a reason for hiding this comment

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

Nice work - I left some comments based on my experience following along with the quick start!

source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
@rustagir rustagir requested a review from norareidy May 28, 2024 20:58
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Run the following commands to install the MongoDB PHP driver and the
MongoDB Doctrine ODM:

Choose a reason for hiding this comment

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

Suggest to add a line that talks about the mongodb-odm-bundle and why we are installing it instead of directly installing mongodb-odm

Quoting the reason from github: "This bundle integrates the Doctrine MongoDB Object Document Mapper (ODM) library into Symfony so that you can persist and retrieve objects to and from MongoDB."

Also add a hyperlink to it - https://github.com/doctrine/DoctrineMongoDBBundle

<https://mongodb-developer.github.io/symfony-mongodb-rental-workshop/>`__
- `Symfony Documentation <https://symfony.com/doc/current/index.html>`__
- `Doctrine ODM Documentation
<https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/index.html>`__

Choose a reason for hiding this comment

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

One more which I missed earlier - https://github.com/doctrine/DoctrineMongoDBBundle

source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
Copy link
Contributor

@norareidy norareidy left a comment

Choose a reason for hiding this comment

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

LGTM with some minor suggestions!

source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
@rustagir
Copy link
Contributor Author

rustagir commented May 30, 2024

@bisht2050 This PR is ready for a technical review by the PHP team.

@mongodb mongodb deleted a comment from rishitb-mongodb May 30, 2024
@bisht2050 bisht2050 requested review from a team and removed request for a team May 31, 2024 10:32
@bisht2050 bisht2050 requested a review from jmikola May 31, 2024 10:32
source/includes/php-frameworks/Restaurant.php Outdated Show resolved Hide resolved
source/includes/php-frameworks/Restaurant.php Outdated Show resolved Hide resolved
class Restaurant
{
#[ODM\Id]
public $id;
Copy link
Member

Choose a reason for hiding this comment

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

@alcaeus: Should an ObjectId type hint be used here? That would warrant importing MongoDB\BSON\ObjectId.

Even if no typing change is made, there's an extra space on this line.

Copy link
Member

Choose a reason for hiding this comment

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

It should be a string, as ODM's Id type converts ObjectIds to strings for better handling in web requests. Off the top of my head I don't know how well Doctrine handles uninitialised properties, so if we want to be cautious it should be a nullable string with default value:

Suggested change
public $id;
public ?string $id = null;

Copy link
Member

Choose a reason for hiding this comment

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

ODM's Id type converts ObjectIds to strings for better handling in web requests

Yes, of course. I want to come out on record here and say that it's been that long since I worked on an app with ODM that I legitimately forgot about that for a hot minute.

Copy link
Contributor Author

@rustagir rustagir Jun 6, 2024

Choose a reason for hiding this comment

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

Changing the field definition was fine, but changing the annotation to #[ODM\Field] for the id field resulted in this error:
No identifier/primary key specified for Entity...
Is this expected? Fixed by changing the annotation back to #[ODM\Id]

Copy link
Member

Choose a reason for hiding this comment

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

#[ODM\Id] is correct. Even though ODM converts ObjectIds to string in the model class, it should be tracked as an identifier.

source/includes/php-frameworks/RestaurantController.php Outdated Show resolved Hide resolved
source/includes/php-frameworks/RestaurantController.php Outdated Show resolved Hide resolved
source/includes/php-frameworks/Restaurant.php Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Show resolved Hide resolved
<https://mongodb-developer.github.io/symfony-mongodb-rental-workshop/>`__
- `Symfony Documentation <https://symfony.com/doc/current/index.html>`__
- `Doctrine ODM Documentation
<https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/index.html>`__
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest reducing the ODM links to the following:

I don't think it's worth linking the individual GitHub repositories (note you aren't doing so for Symfony), as that just distracts from the documentation.

source/php-libraries.txt Outdated Show resolved Hide resolved
@GromNaN GromNaN changed the title DOCSP-39180: symfony qs DOCSP-39180: Symfony Quick Start Jun 3, 2024
source/includes/php-frameworks/symfony/Restaurant.php Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
source/php-frameworks/symfony.txt Show resolved Hide resolved
source/php-frameworks/symfony.txt Show resolved Hide resolved
Specify Routes
``````````````

In the ``config/routes.yaml`` file, add the following routes:
Copy link
Member

Choose a reason for hiding this comment

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

Assuming this was also copied from the dev rel tutorial, I expect there's some redundancy there as well. See: https://symfony.com/doc/current/routing.html

@alcaeus: Should this section be removed entirely? Perhaps "This file sets the following routes in the application" should be relocated to the previous section where the controller class is created, since that ends up defining routes via method attributes.

source/php-frameworks/symfony.txt Outdated Show resolved Hide resolved
Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

LGTM with suggestions and YAML routing configuration removed.

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Types\Type;
Copy link
Member

Choose a reason for hiding this comment

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

This class alias is no longer used.

Suggested change
use Doctrine\ODM\MongoDB\Types\Type;


{% block body %}
<h1>Welcome to the Symfony MongoDB Quickstart!</h1>
{% endblock %}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{% endblock %}
{% endblock %}

Specify Routes
``````````````

In the ``config/routes.yaml`` file, add the following routes:
Copy link
Member

Choose a reason for hiding this comment

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

@rustagir: This entire section can be removed.

@rustagir rustagir merged commit 6d114a0 into mongodb:master Jun 11, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants