@@ -137,6 +137,64 @@ the route ``_controller`` value:
137
137
fully-qualified class name (FQCN). See the
138
138
`FrameworkExtraBundle documentation `_ for details.
139
139
140
+ For example, you could use annotations in the ``HelloController `` defined
141
+ earlier::
142
+
143
+ // src/AppBundle/Controller/HelloController.php
144
+ namespace AppBundle\Controller;
145
+
146
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
147
+ use Symfony\Component\HttpFoundation\Response;
148
+
149
+ class HelloController
150
+ {
151
+ /**
152
+ * @Route("/hello")
153
+ */
154
+ public function indexAction($name)
155
+ {
156
+ // ...
157
+ }
158
+ }
159
+
160
+ With the following routes:
161
+
162
+ .. configuration-block ::
163
+
164
+ .. code-block :: yaml
165
+
166
+ # app/config/routing.yml
167
+ app :
168
+ resource : " @AppBundle/Controller/"
169
+ type : annotation
170
+
171
+ .. code-block :: xml
172
+
173
+ <!-- app/config/routing.xml -->
174
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
175
+ <routes xmlns =" http://symfony.com/schema/routing"
176
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
177
+ xsi : schemaLocation =" http://symfony.com/schema/routing
178
+ http://symfony.com/schema/routing/routing-1.0.xsd" >
179
+
180
+ <!-- the type is required to enable the annotation reader for this resource -->
181
+ <import resource =" @AppBundle/Controller/" type =" annotation" />
182
+ </routes >
183
+
184
+ .. code-block :: php
185
+
186
+ // app/config/routing.php
187
+ use Symfony\Component\Routing\RouteCollection;
188
+
189
+ $collection = new RouteCollection();
190
+ $collection->addCollection(
191
+ // second argument is the type, which is required to enable
192
+ // the annotation reader for this resource
193
+ $loader->import("@AppBundle/Controller/", "annotation")
194
+ );
195
+
196
+ return $collection;
197
+
140
198
.. tip ::
141
199
142
200
If your controller implements the ``__invoke() `` method, you can simply
0 commit comments