@@ -8,6 +8,33 @@ You can also match on the HTTP *host* of the incoming request.
88
99.. configuration-block ::
1010
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+
1138 .. code-block :: yaml
1239
1340 mobile_homepage :
@@ -63,12 +90,39 @@ you can use placeholders in your hostname:
6390
6491.. configuration-block ::
6592
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+
66120 .. code-block :: yaml
67121
68122 projects_homepage :
69123 path : /
70124 host : " {project_name}.example.com"
71- defaults : { _controller: AcmeDemoBundle:Main:mobileHomepage }
125+ defaults : { _controller: AcmeDemoBundle:Main:projectsHomepage }
72126
73127 homepage :
74128 path : /
@@ -83,7 +137,7 @@ you can use placeholders in your hostname:
83137 http://symfony.com/schema/routing/routing-1.0.xsd" >
84138
85139 <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 >
87141 </route >
88142
89143 <route id =" homepage" path =" /" >
@@ -98,7 +152,7 @@ you can use placeholders in your hostname:
98152
99153 $collection = new RouteCollection();
100154 $collection->add('project_homepage', new Route('/', array(
101- '_controller' => 'AcmeDemoBundle:Main:mobileHomepage ',
155+ '_controller' => 'AcmeDemoBundle:Main:projectsHomepage ',
102156 ), array(), array(), '{project_name}.example.com'));
103157
104158 $collection->add('homepage', new Route('/', array(
@@ -113,6 +167,39 @@ instance, if you want to match both ``m.example.com`` and
113167
114168.. configuration-block ::
115169
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+
116203 .. code-block :: yaml
117204
118205 mobile_homepage :
@@ -173,6 +260,39 @@ instance, if you want to match both ``m.example.com`` and
173260
174261 .. configuration-block ::
175262
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+
176296 .. code-block :: yaml
177297
178298 mobile_homepage :
@@ -241,6 +361,22 @@ You can also set the host option on imported routes:
241361
242362.. configuration-block ::
243363
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+
244380 .. code-block :: yaml
245381
246382 acme_hello :
0 commit comments