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:
2828 resource : ' ../src/Controller/'
2929 tags : ['controller.service_arguments']
3030
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+
3150Registering your controller as a service is the first step, but you also need to
3251update your routing config to reference the service properly, so that Symfony
3352knows to use it.
You can’t perform that action at this time.
0 commit comments