Skip to content

Commit 812dbfd

Browse files
committed
minor symfony#6734 Add little caution to add service id for @route annotation (DHager, WouterJ)
This PR was merged into the 2.7 branch. Discussion ---------- Add little caution to add service id for @route annotation Finishes symfony#6258 Original PR description: > I just ran into this problem and it took me a while. Without the `@Route(service="myid")` annotation, the controller was *always* being instantiated without any arguments, completely ignoring my service-definition. > Not sure how far back/forward this applies to other versions. Commits ------- 93bb21c Merge caution with annotations tip ac6b008 Add warning about a pitfall where the controller seems to be instantiated without using the service-definition
2 parents 240f639 + 93bb21c commit 812dbfd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cookbook/controller/service.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ the route ``_controller`` value:
119119
.. tip::
120120

121121
You can also use annotations to configure routing using a controller
122-
defined as a service. See the `FrameworkExtraBundle documentation`_ for
122+
defined as a service. Make sure you specify the service ID in the
123+
``@Route`` annotation. See the `FrameworkExtraBundle documentation`_ for
123124
details.
124125

125126
.. tip::
@@ -338,4 +339,4 @@ controller:
338339

339340
.. _`Controller class source code`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
340341
.. _`base Controller class`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
341-
.. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html
342+
.. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#controller-as-service

0 commit comments

Comments
 (0)