我有一些使用注释路由的symfony代码.我需要从parameters.yml中的设置更改现在主机所在的路由.我看到如果你在routing.yaml中定义路由,这是可能的:http://symfony.com/doc/current/components/routing/hostname_pattern.html 所以我想知道是否可以使用注释和路由中定义的路由.yaml同时,或者如果你只能做一个或另一个(换句话说,我将不得不改变捆绑中的所有路由在routing.yaml中)?虽然我猜不建议同时做两件事,以保持代码清洁.
是的,你可以同时使用两者.事实上正在发生的事情中的Symfony标准版是刚刚从国外进口主要routing.yml
在config.yml
:
framework:
router:
resource: "%kernel.root_dir%/config/routing.yml"
Run Code Online (Sandbox Code Playgroud)
在此routing.yml
您导入您Controllers
的annotation
路由:
routing.yml中:
your_annotation_route:
resource: "@AcmeDemoBundle/Controller/DefaultController.php"
type: annotation
######### you can use regular yml routing here ########
your_yaml_route:
path: /
host: m.example.com
defaults: { _controller: AcmeDemoBundle:Main:mobileHomepage }
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3025 次 |
最近记录: |