Skip to content

Commit 79b36fa

Browse files
committed
feature #12821 [Routing] Documented the option to exclude patterns (javiereguiluz)
This PR was merged into the 4.4 branch. Discussion ---------- [Routing] Documented the option to exclude patterns Fixes #12590. Commits ------- da354da [Routing] Documented the option to exclude patterns
2 parents 444d03e + da354da commit 79b36fa

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

routing.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,8 @@ the common configuration using options when importing the routes.
11741174
# An imported route with an empty URL will become "/blog/"
11751175
# Uncomment this option to make that URL "/blog" instead
11761176
# trailing_slash_on_root: false
1177+
# you can optionally exclude some files/subdirectories when loading annotations
1178+
# exclude: '../src/Controller/{DebugEmailController}.php'
11771179
11781180
.. code-block:: xml
11791181
@@ -1187,11 +1189,13 @@ the common configuration using options when importing the routes.
11871189
<!--
11881190
the 'prefix' value is added to the beginning of all imported route URLs
11891191
the 'name-prefix' value is added to the beginning of all imported route names
1192+
the 'exclude' option defines the files or subdirectories ignored when loading annotations
11901193
-->
11911194
<import resource="../src/Controller/"
11921195
type="annotation"
11931196
prefix="/blog"
1194-
name-prefix="blog_">
1197+
name-prefix="blog_"
1198+
exclude="../src/Controller/{DebugEmailController}.php">
11951199
<!-- these requirements are added to all imported routes -->
11961200
<requirement key="_locale">en|es|fr</requirement>
11971201
</import>
@@ -1211,6 +1215,8 @@ the common configuration using options when importing the routes.
12111215
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
12121216
12131217
return function (RoutingConfigurator $routes) {
1218+
// use the optional fifth argument of import() to exclude some files
1219+
// or subdirectories when loading annotations
12141220
$routes->import('../src/Controller/', 'annotation')
12151221
// this is added to the beginning of all imported route URLs
12161222
->prefix('/blog')
@@ -1224,6 +1230,11 @@ the common configuration using options when importing the routes.
12241230
;
12251231
};
12261232
1233+
.. versionadded:: 4.4
1234+
1235+
The option to exclude some files or subdirectories when loading annotations
1236+
was introduced in Symfony 4.4.
1237+
12271238
In this example, the route of the ``index()`` action will be called ``blog_index``
12281239
and its URL will be ``/blog/``. The route of the ``show()`` action will be called
12291240
``blog_show`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes

0 commit comments

Comments
 (0)