@@ -1846,7 +1846,53 @@ To enable logging out, activate the ``logout`` config parameter under your fire
1846
1846
;
1847
1847
};
1848
1848
1849
- Next, you need to create a route for this URL (but not a controller):
1849
+ ``path `` can be either a route name, or a URI.
1850
+
1851
+ Since Symfony 6.4, you can leverage the
1852
+ :class: `Symfony\\ Bundle\\ SecurityBundle\\ Routing\\ LogoutRouteLoader `
1853
+ to automatically register a route for every logout URI you configured.
1854
+ If your project uses :ref: `Symfony Flex <symfony-flex >`,
1855
+ this is already done for you.
1856
+ Otherwise, you need to import the ``security.route_loader.logout `` service
1857
+ as a routing resource:
1858
+
1859
+ .. configuration-block ::
1860
+
1861
+ .. code-block :: yaml
1862
+
1863
+ # config/routes/security.yaml
1864
+ logout :
1865
+ resource : security.route_loader.logout
1866
+ type : service
1867
+
1868
+ .. code-block :: xml
1869
+
1870
+ <!-- config/routes/security.xml -->
1871
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1872
+ <routes xmlns =" http://symfony.com/schema/routing"
1873
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1874
+ xsi : schemaLocation =" http://symfony.com/schema/routing
1875
+ https://symfony.com/schema/routing/routing-1.0.xsd" >
1876
+
1877
+ <import resource =" security.route_loader.logout" type =" service" />
1878
+ </routes >
1879
+
1880
+ .. code-block :: php
1881
+
1882
+ // config/routes/security.php
1883
+ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
1884
+
1885
+ return static function (RoutingConfigurator $routes): void {
1886
+ $routes->import('security.route_loader.logout', 'service');
1887
+ };
1888
+
1889
+ .. versionadded :: 6.4
1890
+
1891
+ The :class: `Symfony\\ Bundle\\ SecurityBundle\\ Routing\\ LogoutRouteLoader ` was
1892
+ introduced in Symfony 6.4.
1893
+
1894
+ Another option is to create a route matching the name or URI you configured as
1895
+ ``path ``. You don't have to associate a controller because it wouldn't be called:
1850
1896
1851
1897
.. configuration-block ::
1852
1898
0 commit comments