cloakedninjas
cloakedninjas

Reputation: 4176

Symfony: how to configure default options for all routes?

Can I configure the following option in a single place rather than per route?

In my routing.yml file every route has:

options:
    utf8: true

Because of

In Symfony 3.2, there is no need to explicitly set the utf8 option. As soon as Symfony finds a UTF-8 character in the route path or requirements, it will automatically turn on the UTF-8 support. However, this behavior is deprecated and setting the option will be required in Symfony 4.0.

Upvotes: 1

Views: 1471

Answers (1)

gp_sflover
gp_sflover

Reputation: 3500

Using Annotations it's possible in routing.yml to configure default options for all routes defined in AppBundle/Controller/ like this:

app_bundle:
    resource: "@AppBundle/Controller/"
    type:     annotation
    schemes:  "https"
    options: { utf8: true }

Using Yaml you could try putting this directive at the very first place in routing.yml:

app_name:
    path: ^/
    #path: ^/* <-- another attempt to include all routes after the first /
    options: { utf8: true }
    #host: <-- maybe you should specify this and/or other params depending by your needs.

Upvotes: 2

Related Questions