Skip to content

Commit d2d18ef

Browse files
committed
minor #15849 [Bundles] Improve the wording about mapping best practices (javiereguiluz)
This PR was squashed before being merged into the 5.3 branch. Discussion ---------- [Bundles] Improve the wording about mapping best practices Fix #15100. Commits ------- 37195a8 [Bundles] Improve the wording about mapping best practices
2 parents 21fc66c + 37195a8 commit d2d18ef

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

best_practices.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,20 @@ you'll need to configure services (or parts of them) manually.
194194
YAML is the format recommended to configure services because it's friendly to
195195
newcomers and concise, but Symfony also supports XML and PHP configuration.
196196

197-
Use Annotations to Define the Doctrine Entity Mapping
198-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197+
Use Attributes to Define the Doctrine Entity Mapping
198+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199199

200200
Doctrine entities are plain PHP objects that you store in some "database".
201201
Doctrine only knows about your entities through the mapping metadata configured
202202
for your model classes.
203203

204-
Doctrine supports several metadata formats, but it's recommended to use
205-
annotations because they are by far the most convenient and agile way of setting
204+
Doctrine supports several metadata formats, but it's recommended to use PHP
205+
attributes because they are by far the most convenient and agile way of setting
206206
up and looking for mapping information.
207207

208+
If your PHP version doesn't support attributes yet, use annotations, which is
209+
similar but requires installing some extra dependencies in your project.
210+
208211
Controllers
209212
-----------
210213

bundles/best_practices.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ Type Directory
123123
Commands ``src/Command/``
124124
Controllers ``src/Controller/``
125125
Service Container Extensions ``src/DependencyInjection/``
126-
Doctrine ORM entities (when not using annotations) ``src/Entity/``
127-
Doctrine ODM documents (when not using annotations) ``src/Document/``
126+
Doctrine ORM entities ``src/Entity/``
127+
Doctrine ODM documents ``src/Document/``
128128
Event Listeners ``src/EventListener/``
129129
Configuration (routes, services, etc.) ``config/``
130130
Web Assets (CSS, JS, images) ``public/``
@@ -162,6 +162,15 @@ standard Symfony autoloading instead.
162162
A bundle should also not embed third-party libraries written in JavaScript,
163163
CSS or any other language.
164164

165+
Doctrine Entities/Documents
166+
---------------------------
167+
168+
If the bundle includes Doctrine ORM entities and/or ODM documents, it's
169+
recommended to define their mapping using XML files stored in
170+
``Resources/config/doctrine/``. This allows to override that mapping using the
171+
:doc:`standard Symfony mechanism to override bundle parts </bundles/override>`.
172+
This is not possible when using annotations/attributes to define the mapping.
173+
165174
Tests
166175
-----
167176

0 commit comments

Comments
 (0)