【问题标题】:Symfony2 Subdomain Routing - Different BundlesSymfony2 子域路由 - 不同的捆绑包
【发布时间】:2012-05-07 23:47:28
【问题描述】:

编辑 现在有可能在 symfony 2.2 中这样做

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

您也可以在域中使用参数

重新编辑

在将其标记为重复之前,请继续阅读

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

我该怎么做呢?

【问题讨论】:

  • 我正在运行类似的设置。您是否在应用之间共享供应商目录?
  • 是的,我们有自己的内部库,我们在其中放置外部库以支持 Symfony 的核心。我修改了 bin/vendor 文件以及更新每个应用程序的所有内容

标签: php symfony


【解决方案1】:

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

【讨论】:

  • 这太棒了。希望它进入 2.1
【解决方案2】:

看看ExperiumDomainedRoutingBundle,它对我来说非常有效。我没有添加 Bundle-wide 域路由(仅每个控制器使用注释),但我希望它也能工作。

例子:

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

【讨论】:

    猜你喜欢
    • 2016-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-18
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多