FOSOAuthServerBundle + Symfony 4 配置 - 无法导入路由

FOSOAuthServerBundle + Symfony 4 Configuration - can't import routes

我正在尝试根据官方文档配置 Bundle,但是当我添加路由时(如文档中所述)

Import the routing.yml configuration file in app/config/routing.yml: fos_oauth_server_token: resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml" fos_oauth_server_authorize: resource: "@FOSOAuthServerBundle/Resources/config/routing/authorize.xml"

我收到一个错误:

There is no extension able to load the configuration for "fos_oauth_server_token" (in /var/app/ondeck/config/packages/routing.yaml). Looked for namespace "fos_oauth_server_token", found "framework", "twig", "security", "nelmio_cors", "doctrine_cache", "doctrine", "api_platform", "fos_oauth_server" in /var/app/ondeck/config/packages/routing.yaml (which is loaded in resource "/var/app/ondeck/config/packages/routing.yaml").

有什么想法吗?

您在错误的文件中导入了路线。

config/packages/routing.yaml 文件用于路由器配置,不用于定义路由。

你应该有一个 config/routes 目录,在这里导入 FOSOAuthServerBundle 路由。