Symfony:如何为所有路由配置默认选项?

Symfony: how to configure default options for all routes?

我可以在一个地方而不是每个路由配置以下选项吗?

在我的 routing.yml 文件中,每条路线都有:

options:
    utf8: true

因为

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.

使用 Annotations 可以在 routing.yml 中为 AppBundle/Controller/ 中定义的所有路由配置默认选项,如下所示:

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

使用 Yaml 您可以尝试将此指令放在 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.