@@ -1174,6 +1174,8 @@ the common configuration using options when importing the routes.
1174
1174
# An imported route with an empty URL will become "/blog/"
1175
1175
# Uncomment this option to make that URL "/blog" instead
1176
1176
# trailing_slash_on_root: false
1177
+ # you can optionally exclude some files/subdirectories when loading annotations
1178
+ # exclude: '../src/Controller/{DebugEmailController}.php'
1177
1179
1178
1180
.. code-block :: xml
1179
1181
@@ -1187,11 +1189,13 @@ the common configuration using options when importing the routes.
1187
1189
<!--
1188
1190
the 'prefix' value is added to the beginning of all imported route URLs
1189
1191
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
1190
1193
-->
1191
1194
<import resource =" ../src/Controller/"
1192
1195
type =" annotation"
1193
1196
prefix =" /blog"
1194
- name-prefix =" blog_" >
1197
+ name-prefix =" blog_"
1198
+ exclude =" ../src/Controller/{DebugEmailController}.php" >
1195
1199
<!-- these requirements are added to all imported routes -->
1196
1200
<requirement key =" _locale" >en|es|fr</requirement >
1197
1201
</import >
@@ -1211,6 +1215,8 @@ the common configuration using options when importing the routes.
1211
1215
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
1212
1216
1213
1217
return function (RoutingConfigurator $routes) {
1218
+ // use the optional fifth argument of import() to exclude some files
1219
+ // or subdirectories when loading annotations
1214
1220
$routes->import('../src/Controller/', 'annotation')
1215
1221
// this is added to the beginning of all imported route URLs
1216
1222
->prefix('/blog')
@@ -1224,6 +1230,11 @@ the common configuration using options when importing the routes.
1224
1230
;
1225
1231
};
1226
1232
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
+
1227
1238
In this example, the route of the ``index() `` action will be called ``blog_index ``
1228
1239
and its URL will be ``/blog/ ``. The route of the ``show() `` action will be called
1229
1240
``blog_show `` and its URL will be ``/blog/{_locale}/posts/{slug} ``. Both routes
0 commit comments