@@ -18,25 +18,26 @@ knows to use it.
18
18
19
19
Use the ``service_id::method_name `` syntax to refer to the controller method.
20
20
If the service id is the fully-qualified class name (FQCN) of your controller,
21
- as Symfony recommends, then you can use something like:
22
- ``App\Controller\HelloController::index ``:
21
+ as Symfony recommends, then the syntax is the same as if the controller was not
22
+ a service like: ``App\Controller\HelloController::index ``:
23
23
24
24
.. configuration-block ::
25
25
26
26
.. code-block :: php-annotations
27
27
28
28
// src/Controller/HelloController.php
29
29
30
- // You need to use Sensio's annotation to specify a service id
31
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
32
- // ...
30
+ use Symfony\Component\Routing\Annotation\Route;
33
31
34
- /**
35
- * @Route(service="App\Controller\HelloController::index")
36
- */
37
32
class HelloController
38
33
{
39
- // ...
34
+ /**
35
+ * @Route("/hello", name="hello")
36
+ */
37
+ public function index()
38
+ {
39
+ // ...
40
+ }
40
41
}
41
42
42
43
.. code-block :: yaml
@@ -75,7 +76,7 @@ Invokable Controllers
75
76
76
77
If your controller implements the ``__invoke() `` method - popular with the
77
78
Action-Domain-Response (ADR) pattern, you can simply refer to the service id
78
- (``App\Controller\HelloController `` for example).
79
+ without the method (``App\Controller\HelloController `` for example).
79
80
80
81
Alternatives to base Controller Methods
81
82
---------------------------------------
@@ -89,7 +90,7 @@ The base `Controller class source code`_ is a great way to see how to accomplish
89
90
common tasks. For example, ``$this->render() `` is usually used to render a Twig
90
91
template and return a Response. But, you can also do this directly:
91
92
92
- In a controller that's defined as a service, you can instead inject the ``templating ``
93
+ In a controller that's defined as a service, you can instead inject the ``twig ``
93
94
service and use it directly::
94
95
95
96
// src/Controller/HelloController.php
0 commit comments