From a152e1bc0daeb903a38a2c0df4ceb811accb1a16 Mon Sep 17 00:00:00 2001 From: Camille TEROL Date: Sat, 29 Jan 2022 22:56:33 +0100 Subject: [PATCH 1/2] Document the exclude parameter --- routing.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/routing.rst b/routing.rst index 56eeefcd7fd..b02672cd52b 100644 --- a/routing.rst +++ b/routing.rst @@ -2253,6 +2253,35 @@ defined as annotations: The Security component provides :doc:`another way to enforce HTTP or HTTPS ` via the ``requires_channel`` setting. + + +Excluding a path from lookup +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You might want to prefix some controllers in a specific folder with a uri. To +do this, you would need a different configuration for your general controllers +and the controllers in this folder. + +In that case, you can use the ``exclude`` keyword to exclude a path from being +looked up to avoid duplicate routes. To make sure that the exclude parameter is +taken into account, you will also need to add a ``*`` character at the end of +your resource parameter. + +.. code-block:: yaml + # config/routes/annotations.yaml + controllers: + resource: ../../src/Controller/* + exclude: ../../src/Controller/Api + type: annotation + + api_controllers: + resource: ../../src/Controller/Api/ + prefix: /api/ + name_prefix: api_ + type: annotation + kernel: + resource: ../../src/Kernel.php + type: annotation Troubleshooting --------------- From eb43af1fe213212916c5f6c711ba8d59543a0713 Mon Sep 17 00:00:00 2001 From: Camille TEROL Date: Sat, 29 Jan 2022 23:03:23 +0100 Subject: [PATCH 2/2] Fix some errors in the syntax --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index b02672cd52b..2a0c57708c9 100644 --- a/routing.rst +++ b/routing.rst @@ -2254,7 +2254,6 @@ defined as annotations: :doc:`another way to enforce HTTP or HTTPS ` via the ``requires_channel`` setting. - Excluding a path from lookup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2268,6 +2267,7 @@ taken into account, you will also need to add a ``*`` character at the end of your resource parameter. .. code-block:: yaml + # config/routes/annotations.yaml controllers: resource: ../../src/Controller/*