-
Notifications
You must be signed in to change notification settings - Fork 300
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
Conversation
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:
We should also rename the page title ( |
source/php-frameworks/symfony.txt
Outdated
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 |
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.
MongoDB Doctrine ODM should hyperlink to https://github.com/doctrine/mongodb-odm
<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>`__ |
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.
Suggest to add https://github.com/doctrine/mongodb-odm as well
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.
One more which I missed earlier - https://github.com/doctrine/DoctrineMongoDBBundle
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 would suggest reducing the ODM links to the following:
- https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/index.html
- https://www.doctrine-project.org/projects/doctrine-mongodb-bundle/en/latest/index.html
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.
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.
Nice work - I left some comments based on my experience following along with the quick start!
source/php-frameworks/symfony.txt
Outdated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Run the following commands to install the MongoDB PHP driver and the | ||
MongoDB Doctrine ODM: |
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.
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>`__ |
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.
One more which I missed earlier - https://github.com/doctrine/DoctrineMongoDBBundle
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 with some minor suggestions!
@bisht2050 This PR is ready for a technical review by the PHP team. |
class Restaurant | ||
{ | ||
#[ODM\Id] | ||
public $id; |
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.
@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.
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.
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:
public $id; | |
public ?string $id = null; |
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.
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.
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.
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]
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.
#[ODM\Id]
is correct. Even though ODM converts ObjectIds to string in the model class, it should be tracked as an identifier.
<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>`__ |
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 would suggest reducing the ODM links to the following:
- https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/index.html
- https://www.doctrine-project.org/projects/doctrine-mongodb-bundle/en/latest/index.html
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-frameworks/symfony.txt
Outdated
Specify Routes | ||
`````````````` | ||
|
||
In the ``config/routes.yaml`` file, add the following routes: |
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.
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.
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 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; |
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 class alias is no longer used.
use Doctrine\ODM\MongoDB\Types\Type; |
|
||
{% block body %} | ||
<h1>Welcome to the Symfony MongoDB Quickstart!</h1> | ||
{% endblock %} |
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.
{% endblock %} | |
{% endblock %} | |
source/php-frameworks/symfony.txt
Outdated
Specify Routes | ||
`````````````` | ||
|
||
In the ``config/routes.yaml`` file, add the following routes: |
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.
@rustagir: This entire section can be removed.
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