@@ -8,6 +8,33 @@ You can also match on the HTTP *host* of the incoming request.
8
8
9
9
.. configuration-block ::
10
10
11
+ .. code-block :: php-annotations
12
+
13
+ // src/Acme/DemoBundle/Controller/MainController.php
14
+ namespace Acme\DemoBundle\Controller;
15
+
16
+ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
17
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
18
+
19
+ class MainController extends Controller
20
+ {
21
+ /**
22
+ * @Route("/", name="mobile_homepage", host="m.example.com")
23
+ */
24
+ public function mobileHomepageAction()
25
+ {
26
+ // ...
27
+ }
28
+
29
+ /**
30
+ * @Route("/", name="homepage")
31
+ */
32
+ public function homepageAction()
33
+ {
34
+ // ...
35
+ }
36
+ }
37
+
11
38
.. code-block :: yaml
12
39
13
40
mobile_homepage :
@@ -63,12 +90,39 @@ you can use placeholders in your hostname:
63
90
64
91
.. configuration-block ::
65
92
93
+ .. code-block :: php-annotations
94
+
95
+ // src/Acme/DemoBundle/Controller/MainController.php
96
+ namespace Acme\DemoBundle\Controller;
97
+
98
+ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
99
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
100
+
101
+ class MainController extends Controller
102
+ {
103
+ /**
104
+ * @Route("/", name="projects_homepage", host="{project_name}.example.com")
105
+ */
106
+ public function projectsHomepageAction()
107
+ {
108
+ // ...
109
+ }
110
+
111
+ /**
112
+ * @Route("/", name="homepage")
113
+ */
114
+ public function homepageAction()
115
+ {
116
+ // ...
117
+ }
118
+ }
119
+
66
120
.. code-block :: yaml
67
121
68
122
projects_homepage :
69
123
path : /
70
124
host : " {project_name}.example.com"
71
- defaults : { _controller: AcmeDemoBundle:Main:mobileHomepage }
125
+ defaults : { _controller: AcmeDemoBundle:Main:projectsHomepage }
72
126
73
127
homepage :
74
128
path : /
@@ -83,7 +137,7 @@ you can use placeholders in your hostname:
83
137
http://symfony.com/schema/routing/routing-1.0.xsd" >
84
138
85
139
<route id =" projects_homepage" path =" /" host =" {project_name}.example.com" >
86
- <default key =" _controller" >AcmeDemoBundle:Main:mobileHomepage </default >
140
+ <default key =" _controller" >AcmeDemoBundle:Main:projectsHomepage </default >
87
141
</route >
88
142
89
143
<route id =" homepage" path =" /" >
@@ -98,7 +152,7 @@ you can use placeholders in your hostname:
98
152
99
153
$collection = new RouteCollection();
100
154
$collection->add('project_homepage', new Route('/', array(
101
- '_controller' => 'AcmeDemoBundle:Main:mobileHomepage ',
155
+ '_controller' => 'AcmeDemoBundle:Main:projectsHomepage ',
102
156
), array(), array(), '{project_name}.example.com'));
103
157
104
158
$collection->add('homepage', new Route('/', array(
@@ -113,6 +167,39 @@ instance, if you want to match both ``m.example.com`` and
113
167
114
168
.. configuration-block ::
115
169
170
+ .. code-block :: php-annotations
171
+
172
+ // src/Acme/DemoBundle/Controller/MainController.php
173
+ namespace Acme\DemoBundle\Controller;
174
+
175
+ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
176
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
177
+
178
+ class MainController extends Controller
179
+ {
180
+ /**
181
+ * @Route(
182
+ * "/",
183
+ * name="mobile_homepage",
184
+ * host="{subdomain}.example.com",
185
+ * defaults={"subdomain"="m"},
186
+ * requirements={"subdomain"="m|mobile"}
187
+ * )
188
+ */
189
+ public function mobileHomepageAction()
190
+ {
191
+ // ...
192
+ }
193
+
194
+ /**
195
+ * @Route("/", name="homepage")
196
+ */
197
+ public function homepageAction()
198
+ {
199
+ // ...
200
+ }
201
+ }
202
+
116
203
.. code-block :: yaml
117
204
118
205
mobile_homepage :
@@ -173,6 +260,39 @@ instance, if you want to match both ``m.example.com`` and
173
260
174
261
.. configuration-block ::
175
262
263
+ .. code-block :: php-annotations
264
+
265
+ // src/Acme/DemoBundle/Controller/MainController.php
266
+ namespace Acme\DemoBundle\Controller;
267
+
268
+ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
269
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
270
+
271
+ class MainController extends Controller
272
+ {
273
+ /**
274
+ * @Route(
275
+ * "/",
276
+ * name="mobile_homepage",
277
+ * host="m.{domain}",
278
+ * defaults={"domain"="%domain%"},
279
+ * requirements={"domain"="%domain%"}
280
+ * )
281
+ */
282
+ public function mobileHomepageAction()
283
+ {
284
+ // ...
285
+ }
286
+
287
+ /**
288
+ * @Route("/", name="homepage")
289
+ */
290
+ public function homepageAction()
291
+ {
292
+ // ...
293
+ }
294
+ }
295
+
176
296
.. code-block :: yaml
177
297
178
298
mobile_homepage :
@@ -241,6 +361,22 @@ You can also set the host option on imported routes:
241
361
242
362
.. configuration-block ::
243
363
364
+ .. code-block :: php-annotations
365
+
366
+ // src/Acme/HelloBundle/Controller/MainController.php
367
+ namespace Acme\HelloBundle\Controller;
368
+
369
+ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
370
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
371
+
372
+ /**
373
+ * @Route(host="hello.example.com")
374
+ */
375
+ class MainController extends Controller
376
+ {
377
+ // ...
378
+ }
379
+
244
380
.. code-block :: yaml
245
381
246
382
acme_hello :
0 commit comments