File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,25 @@ in method parameters:
28
28
resource : ' ../src/Controller/'
29
29
tags : ['controller.service_arguments']
30
30
31
+ If you prefer, you can use the ``#[AsController] `` PHP attribute to automatically
32
+ apply the ``controller.service_arguments `` tag to your controller services::
33
+
34
+ // src/Controller/HelloController.php
35
+ namespace App\Controller;
36
+
37
+ use Symfony\Component\HttpKernel\Attribute\AsController;
38
+ use Symfony\Component\Routing\Annotation\Route;
39
+
40
+ #[AsController]
41
+ class HelloController
42
+ {
43
+ #[Route('/hello', name: 'hello', methods: ['GET'])]
44
+ public function index()
45
+ {
46
+ // ...
47
+ }
48
+ }
49
+
31
50
Registering your controller as a service is the first step, but you also need to
32
51
update your routing config to reference the service properly, so that Symfony
33
52
knows to use it.
You can’t perform that action at this time.
0 commit comments