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