File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,22 @@ a service like: ``App\Controller\HelloController::index``:
41
41
}
42
42
}
43
43
44
+ .. code-block :: php-attributes
45
+
46
+ // src/Controller/HelloController.php
47
+ namespace App\Controller;
48
+
49
+ use Symfony\Component\Routing\Annotation\Route;
50
+
51
+ class HelloController
52
+ {
53
+ #[Route('/hello', name: 'hello', methods: ['GET'])]
54
+ public function index()
55
+ {
56
+ // ...
57
+ }
58
+ }
59
+
44
60
.. code-block :: yaml
45
61
46
62
# config/routes.yaml
@@ -105,6 +121,23 @@ which is a common practice when following the `ADR pattern`_
105
121
}
106
122
}
107
123
124
+ .. code-block :: php-attributes
125
+
126
+ // src/Controller/Hello.php
127
+ namespace App\Controller;
128
+
129
+ use Symfony\Component\HttpFoundation\Response;
130
+ use Symfony\Component\Routing\Annotation\Route;
131
+
132
+ #[Route('/hello/{name}', name: 'hello')]
133
+ class Hello
134
+ {
135
+ public function __invoke($name = 'World')
136
+ {
137
+ return new Response(sprintf('Hello %s!', $name));
138
+ }
139
+ }
140
+
108
141
.. code-block :: yaml
109
142
110
143
# config/routes.yaml
You can’t perform that action at this time.
0 commit comments