File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -181,8 +181,9 @@ hold the kernel. Now it looks like this::
181181 $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml')->prefix('/_profiler');
182182 }
183183
184- // load the annotation routes
185- $routes->import(__DIR__.'/Controller/', 'annotation');
184+ // load the routes defined as PHP attributes
185+ // (use 'annotation' as the second argument if you define routes as annotations)
186+ $routes->import(__DIR__.'/Controller/', 'attribute');
186187 }
187188
188189 // optional, to use the standard Symfony cache directory
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ Symfony provides several route loaders for the most common needs:
7070 // loads routes from the given routing file stored in some bundle
7171 $routes->import('@AcmeBundle/Resources/config/routing.yaml');
7272
73- // loads routes from the PHP annotations of the controllers found in that directory
73+ // loads routes from the PHP attributes (#[Route(...)]) of the controllers found in that directory
74+ $routes->import('../src/Controller/', 'attribute');
75+
76+ // loads routes from the PHP annotations (@Route(...)) of the controllers found in that directory
7477 $routes->import('../src/Controller/', 'annotation');
7578
7679 // loads routes from the YAML or XML files found in that directory
@@ -80,6 +83,11 @@ Symfony provides several route loaders for the most common needs:
8083 $routes->import('@AcmeOtherBundle/Resources/config/routing/', 'directory');
8184 };
8285
86+ .. versionadded :: 6.1
87+
88+ The ``attribute `` value of the second argument of ``import() `` was introduced
89+ in Symfony 6.1.
90+
8391.. note ::
8492
8593 When importing resources, the key (e.g. ``app_file ``) is the name of the collection.
You can’t perform that action at this time.
0 commit comments