E5E7 Document the exclude parameter by camilleterol · Pull Request #16456 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,35 @@ defined as annotations:
The Security component provides
:doc:`another way to enforce HTTP or HTTPS </security/force_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
---------------
Expand Down
0