Symfony:根据URL加载特定配置

时间:2013-04-12 14:28:30

标签: url symfony configuration parameters

我有一个标准的Symfony 2.2项目和我自己的小Bundle。 我有一条路线说我有一个/{customer},我可以在控制器中读到customer,到目前为止一直很好。

但是,我还想加载名为config_{customer}.yml的配置,我该怎么做?

1 个答案:

答案 0 :(得分:0)

您可以在匹配给定主机时加载特定包。然后该捆绑包将加载其services.yml文件。

# app/config/routing.yml
acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    host:     "hello.example.com"

您的包的服务文件:

# src/Acme/HelloBundle/Resources/config/services.yml
acme_hello:
    param: value

有关详细信息,请参阅以下URL。 http://symfony.com/doc/master/components/routing/hostname_pattern.html

相关问题