【问题标题】:Symfony2: Add a prefix route to a bundleSymfony2:将前缀路由添加到捆绑包
【发布时间】:2015-01-17 08:24:50
【问题描述】:

我正在使用 Symfony2,并且我有一个包含多个控制器的包。我想为所有这些都有一个共同的前缀路由。

类似这样的:

bundle_path/controller1_path
bundle_path/controller2_path
bundle_path/controller3_path

等等。

有没有办法在不将 bundle_path 写入每个控制器的情况下做到这一点?

【问题讨论】:

  • 这有什么问题?
  • 你可以这样做,你必须创建你自己的RouteLoader。

标签: symfony routing


【解决方案1】:

您可以在 routing.yml 文件中添加 前缀 来表示捆绑包的路由。例如:

acme_customer_area_frontend:
    resource: "@AcmeCustomerAreaFrontendBundle/Resources/config/routing.yml"
    prefix:   /customer/frontend

希望有帮助

【讨论】:

  • 谢谢,正是我需要的!它也适用于注释(我使用)。 acme_customer_area_frontend:资源:“@AcmeCustomerAreaFrontendBundle/Controller/”类型:注解前缀:/customer/frontend
  • 嗨@Fromage,如果您认为我的回答有帮助,请考虑支持我的回答
  • 刚刚做过,本来会更早做的,但我需要 15 分的声誉才能做到这一点(这里是新用户);)再次感谢
猜你喜欢
  • 2016-02-09
  • 1970-01-01
  • 2015-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-26
相关资源
最近更新 更多