2012-05-07 27 views
8

编辑 现在有在symfony中这样做的2.2Symfony2的子域路由 - 不同的包

PlatformFooBundle: 
    resource: "@PlatformFooBundle/Resources/config/routing.php" 
    domain: foo.testdomain.com 

PlatformBarBundle: 
    resource: "@PlatformBarBundle/Resources/config/routing.php" 
    domain: bar.testdomain.com 

PlatformBazBundle: 
    resource: "@PlatformBazBundle/Resources/config/routing.php" 
    domain: baz.testdomain.com 

可以在域中使用的参数以及

编辑OVER

的可能性

将此标记为一个副本之前,请阅读

http://www.craftitonline.com/2011/08/symfony2-locale-on-subdomains-not-on-the-url-path/

我读过这篇文章,但它不帮助我做什么我试图做。

我有3个不同的应用程序运行在相同的域名,与单独的子域。目前,他们都在自己的symfony安装中运行,我想摆脱它。

foo.testdomain.com 
bar.testdomain.com 
baz.testdomain.com 
每一种

使用不同的包

PlatformFooBundle 
PlatformBarBundle 
PlatformBazBundle 

和他们每个人都有自己的路由定义。

基本上,我想这是什么

PlatformFooBundle: 
    resource: "@PlatformFooBundle/Resources/config/routing.php" 
    subdomain: www|devwww 

PlatformBarBundle: 
    resource: "@PlatformBarBundle/Resources/config/routing.php" 
    subdomain: bar|devbar 

PlatformBazBundle: 
    resource: "@PlatformBazBundle/Resources/config/routing.php" 
    subdomain: baz|devbaz 

我怎么会去这样做?

+0

我运行一个类似的设置。您是否在应用程序之间共享供应商目录? – noisebleed

+0

是的,我们有我们自己的内部库,我们在这里放置外部库,如Symfony的核心。我修改了bin/vendor文件和一切以更新每个应用程序 – Ascherer

回答

6

有一个discussion正在添加此功能。

+0

这将会很棒。希望它进入到2.1 – Ascherer

+1

仍在等待这.... – Ascherer

+6

如果有人正在阅读此,它已经在Sf2.2 – luiges90

1

看看ExperiumDomainedRoutingBundle,这对我来说真的很好。我没有添加一个Bundle范围的域路由(只有每个控制器使用注释),但我也希望这个工作。

例子:

/** 
* @Route("/", name="frontend_show", options = {"domain_pattern"="{username}.%base_domain%"}) 
* @Route("/u/{username}", name="private_show") 
* @Template("SiteBundle:Frontend:show.html.twig") 
*/ 
+0

请更新链接,谢谢。 –