Skip to content

Commit 1deee7b

Browse files
committed
added a note about route and service names in redistributable bundles
1 parent 444ff7f commit 1deee7b

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

cookbook/bundles/best_practices.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class name.
5959
and always add a ``Bundle`` subnamespace; for example:
6060
:class:`Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle`.
6161

62+
Each bundle has an alias, which is the lower-cased short version of the bundle
63+
name using underscores (``acme_hello`` for ``AcmeHelloBundle``, or
64+
``acme_social_blog`` for ``Acme\Social\BlogBundle`` for instance). This alias
65+
is used to enforce uniqueness within a bundle (see below for some usage
66+
examples).
67+
6268
Directory Structure
6369
-------------------
6470

@@ -179,7 +185,8 @@ All classes and functions must come with full PHPDoc.
179185

180186
Extensive documentation should also be provided in the :doc:`reStructuredText
181187
</contributing/documentation/format>` format, under the ``Resources/doc/``
182-
directory; the ``Resources/doc/index.rst`` file is the only mandatory file.
188+
directory; the ``Resources/doc/index.rst`` file is the only mandatory file and
189+
must be the entry point for the documentation.
183190

184191
Controllers
185192
-----------
@@ -198,6 +205,13 @@ instead.
198205
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` methods,
199206
you will see that they are only nice shortcuts to ease the learning curve.
200207

208+
Routing
209+
-------
210+
211+
If the bundle provides routes, they must be prefixed with the bundle alias.
212+
For an AcmeBlogBundle for instance, all routes must be prefixed with
213+
``acme_blog_``.
214+
201215
Templates
202216
---------
203217

@@ -220,12 +234,10 @@ using the Symfony2 built-in mechanisms.
220234

221235
For simple configuration settings, rely on the default ``parameters`` entry of
222236
the Symfony2 configuration. Symfony2 parameters are simple key/value pairs; a
223-
value being any valid PHP value. Each parameter name should start with a
224-
lower-cased short version of the bundle name using underscores (``acme_hello``
225-
for ``AcmeHelloBundle``, or ``acme_social_blog`` for ``Acme\Social\BlogBundle``
226-
for instance), though this is just a best-practice suggestion. The rest of
227-
the parameter name will use a period (``.``) to separate different parts
228-
(e.g. ``acme_hello.email.from``).
237+
value being any valid PHP value. Each parameter name should start with the
238+
bundle alias, though this is just a best-practice suggestion. The rest of the
239+
parameter name will use a period (``.``) to separate different parts (e.g.
240+
``acme_hello.email.from``).
229241

230242
The end user can provide values in any configuration file:
231243

@@ -261,6 +273,11 @@ Retrieve the configuration parameters in your code from the container::
261273
Even if this mechanism is simple enough, you are highly encouraged to use the
262274
semantic configuration described in the cookbook.
263275

276+
.. note::
277+
278+
If you are defining services, they should also be prefixed with the bundle
279+
alias.
280+
264281
Learn more from the Cookbook
265282
----------------------------
266283

0 commit comments

Comments
 (0)