diff --git a/routing.rst b/routing.rst index d7397f16978..5d69151732c 100644 --- a/routing.rst +++ b/routing.rst @@ -1174,6 +1174,8 @@ the common configuration using options when importing the routes. # An imported route with an empty URL will become "/blog/" # Uncomment this option to make that URL "/blog" instead # trailing_slash_on_root: false + # you can optionally exclude some files/subdirectories when loading annotations + # exclude: '../src/Controller/{DebugEmailController}.php' .. code-block:: xml @@ -1187,11 +1189,13 @@ the common configuration using options when importing the routes. + name-prefix="blog_" + exclude="../src/Controller/{DebugEmailController}.php"> en|es|fr @@ -1211,6 +1215,8 @@ the common configuration using options when importing the routes. use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return function (RoutingConfigurator $routes) { + // use the optional fifth argument of import() to exclude some files + // or subdirectories when loading annotations $routes->import('../src/Controller/', 'annotation') // this is added to the beginning of all imported route URLs ->prefix('/blog') @@ -1224,6 +1230,11 @@ the common configuration using options when importing the routes. ; }; +.. versionadded:: 4.4 + + The option to exclude some files or subdirectories when loading annotations + was introduced in Symfony 4.4. + In this example, the route of the ``index()`` action will be called ``blog_index`` and its URL will be ``/blog/``. The route of the ``show()`` action will be called ``blog_show`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes