Description
We seem to have no documentation on the available routing loader types that you configure when loading a resource in app/config/routing.yml
. Nor do we document how Symfony determines the loader when no type is used and what the benefit of the type setting is. I've seem a couple of people asking for such docs the last weeks.
I think this can be added to book/routing
directly in the "Including External Routing Resources" section.
Available loaders: yaml, php, xml, annotation (if SensioFrameworkExtraBundle is registered)
How loaders are choosen
When no type is configured, it's based on the extension. The first matching loader will be used. When a type is configured, both extension and type are taken into account. For instance, a file custom_routing.yml
with type yaml
will be loaded by the yaml loader, while a custom_routing.php
with type yaml
will not be loaded, as no loader matches both the .php
extension and the yaml
type.
The benefit of the type setting
Types allow you to use different loaders for the same extension, for instance a .php
extension can be loaded by both the PHP and the annotation loader. Using the type annotation
will make sure it's loaded by the annotation loader.
/refs symfony/symfony#13623