Skip to content

Document the exclude parameter #16456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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