diff --git a/routing.rst b/routing.rst
index 72534ea3d00..b0ebdf341f8 100644
--- a/routing.rst
+++ b/routing.rst
@@ -37,15 +37,22 @@ Otherwise, create the following file manually:
# config/routes/attributes.yaml
controllers:
resource: ../../src/Controller/
- type: attribute
+ type: attribute@App\Controller
kernel:
- resource: ../../src/Kernel.php
+ resource: App\Kernel
type: attribute
-This configuration tells Symfony to look for routes defined as
-attributes in any PHP class stored in the ``src/Controller/``
-directory.
+This configuration tells Symfony to look for routes defined as attributes on
+classes declared in the ``App\Controller`` namespace which are stored in the
+``src/Controller/`` directory which follows the PSR-4 standard. In addition,
+our kernel can act as a controller as well which is especially useful for small
+applications that use Symfony as a microframework.
+
+.. versionadded:: 6.2
+
+ The possibility to suffix the ``attribute`` resource type with a PSR-4
+ namespace root was introduced in Symfony 6.2.
Suppose you want to define a route for the ``/blog`` URL in your application. To
do so, create a :doc:`controller class ` like the following:
diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst
index 7dd81a0f8b5..12538a78311 100644
--- a/routing/custom_route_loader.rst
+++ b/routing/custom_route_loader.rst
@@ -24,11 +24,21 @@ Symfony provides several route loaders for the most common needs:
# loads routes from the given routing file stored in some bundle
resource: '@AcmeBundle/Resources/config/routing.yaml'
+ app_psr4:
+ # loads routes from the PHP attributes of the controllers found in the given PSR-4 namespace root
+ resource: '../src/Controller/'
+ type: attribute@App\Controller
+
app_attributes:
# loads routes from the PHP attributes of the controllers found in that directory
resource: '../src/Controller/'
type: attribute
+ app_class_attributes:
+ # loads routes from the PHP attributes of the given class
+ resource: App\Controller\MyController
+ type: attribute
+
app_directory:
# loads routes from the YAML, XML or PHP files found in that directory
resource: '../legacy/routing/'
@@ -51,9 +61,15 @@ Symfony provides several route loaders for the most common needs:
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: