Alana Storm
Alana Storm

Reputation: 166106

What Does the `type:` Configuration in a Symfony Route Configuration Control?

What does the type: configuration in a Symfony routing file control? What are its valid values?

I can't find this configuration field explicitly documented anywhere. It's referenced indirectly in Symfony's routing documentation.

app_directory:
    resource: '../legacy/routing/'
    type:     directory

and seems related to loading in additional routes. However, its behavior (or all its allowed values) doesn't seem to be explicatly defined anywhere. I can make a guess that it somehow tells Symfony how to load the external routes, but I'd love to know

  1. Is my guess correct?
  2. Are there valid values other than directory or annotation?
  3. Is this formally documented anywhere?
  4. Is there a spot in the Symfony internals that would be a good place to start finding these answers for myself?

Upvotes: 1

Views: 114

Answers (1)

Paweł Napierała
Paweł Napierała

Reputation: 1755

You can find how the type works in the Symfony documentation, see code below. It controls if the routes should be loaded from the PHP annotations or the YAML or XML files found in that (bundle) directory.

app_file:
    # loads routes from the given routing file stored in some bundle
    resource: '@AcmeOtherBundle/Resources/config/routing.yaml'

app_annotations:
    # loads routes from the PHP annotations of the controllers found in that directory
    resource: '../src/Controller/'
    type:     annotation

app_directory:
    # loads routes from the YAML or XML files found in that directory
    resource: '../legacy/routing/'
    type:     directory

app_bundle:
    # loads routes from the YAML or XML files found in some bundle directory
    resource: '@AppBundle/Resources/config/routing/public/'
    type:     directory

Upvotes: 1

Related Questions