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``:
4141 }
4242 }
4343
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+
4460 .. code-block :: yaml
4561
4662 # config/routes.yaml
@@ -105,6 +121,23 @@ which is a common practice when following the `ADR pattern`_
105121 }
106122 }
107123
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+
108141 .. code-block :: yaml
109142
110143 # config/routes.yaml
You can’t perform that action at this time.
0 commit comments