Symfony2:将前缀路由添加到包
Symfony2: Add a prefix route to a bundle
我正在使用 Symfony2,我有一个包含多个控制器的包。我想为所有这些设置一个通用的前缀路由。
像这样:
bundle_path/controller1_path
bundle_path/controller2_path
bundle_path/controller3_path
等
有没有办法不用将 bundle_path 写入每个控制器就可以做到这一点?
您可以添加 前缀 以在 routing.yml 文件中添加包的路径。例如:
acme_customer_area_frontend:
resource: "@AcmeCustomerAreaFrontendBundle/Resources/config/routing.yml"
prefix: /customer/frontend
希望对您有所帮助
我正在使用 Symfony2,我有一个包含多个控制器的包。我想为所有这些设置一个通用的前缀路由。
像这样:
bundle_path/controller1_path
bundle_path/controller2_path
bundle_path/controller3_path
等
有没有办法不用将 bundle_path 写入每个控制器就可以做到这一点?
您可以添加 前缀 以在 routing.yml 文件中添加包的路径。例如:
acme_customer_area_frontend:
resource: "@AcmeCustomerAreaFrontendBundle/Resources/config/routing.yml"
prefix: /customer/frontend
希望对您有所帮助