简体   繁体   English

基于Symfony中请求URL的不同配置

[英]Different configuration based on request URL in Symfony

I need to specify different configuration options for Symfony2 (eg session cookie name, locale), depending on requested URL. 我需要根据请求的URL为Symfony2指定不同的配置选项(例如,会话cookie名称,语言环境)。 Currently I am just matching URL with regexp in app.dev file, and loading different environments (with different config files), but this way seems to be a hack. 目前,我只是将URL与app.dev文件中的regexp匹配,并加载不同的环境(具有不同的配置文件),但是这种方式似乎是一种黑客。 Is there a better way to achieve it? 有没有更好的方法来实现呢?

For example, now for url: http://example.com/de/ , I am loading prod_de environment, for http://example.com/it/ , I am loading prod_it. 例如,现在对于url: http : //example.com/de/ ,我正在加载prod_de环境,对于http://example.com/it/ ,我正在加载prod_it。

For Local: You Can Specify Local In Url By "{_locale}" Placeholder, The Best Way Is Use From Event Listener: kernel.request Event 对于本地:您可以通过“ {_locale}”占位符在Url中指定本地,最好的方法是从事件监听器中使用:kernel.request事件

Read This Article 阅读此文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM