@@ -1528,6 +1528,114 @@ A possible solution is to change the parameter requirements to be more permissiv
15281528 as the token and the format will be empty. This can be solved by replacing
15291529 the ``.+ `` requirement by ``[^.]+ `` to allow any character except dots.
15301530
1531+ .. _routing-alias :
1532+
1533+ Route Aliasing
1534+ --------------
1535+
1536+ Route alias allow you to have multiple name for the same route:
1537+
1538+ .. configuration-block ::
1539+
1540+ .. code-block :: yaml
1541+
1542+ # config/routes.yaml
1543+ new_route_name :
1544+ alias : original_route_name
1545+
1546+ .. code-block :: xml
1547+
1548+ <!-- config/routes.xml -->
1549+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1550+ <routes xmlns =" http://symfony.com/schema/routing"
1551+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1552+ xsi : schemaLocation =" http://symfony.com/schema/routing
1553+ https://symfony.com/schema/routing/routing-1.0.xsd" >
1554+
1555+ <route id =" new_route_name" alias =" original_route_name" />
1556+ </routes >
1557+
1558+ .. code-block :: php
1559+
1560+ // config/routes.php
1561+ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
1562+
1563+ return function (RoutingConfigurator $routes) {
1564+ $routes->alias('new_route_name', 'original_route_name');
1565+ };
1566+
1567+ In this example, both ``original_route_name `` and ``new_route_name `` routes can
1568+ be used in the application and will produce the same result.
1569+
1570+ .. _routing-alias-deprecation :
1571+
1572+ Deprecating Route Aliases
1573+ ~~~~~~~~~~~~~~~~~~~~~~~~~
1574+
1575+ If some route alias should no longer be used (because it is outdated or
1576+ you decided not to maintain it anymore), you can deprecate its definition:
1577+
1578+ .. configuration-block ::
1579+
1580+ .. code-block :: yaml
1581+
1582+ new_route_name :
1583+ alias : original_route_name
1584+
1585+ # this outputs the following generic deprecation message:
1586+ # Since acme/package 1.2: The "new_route_name" route alias is deprecated. You should stop using it, as it will be removed in the future.
1587+ deprecated :
1588+ package : ' acme/package'
1589+ version : ' 1.2'
1590+
1591+ # you can also define a custom deprecation message (%alias_id% placeholder is available)
1592+ deprecated :
1593+ package : ' acme/package'
1594+ version : ' 1.2'
1595+ message : ' The "%alias_id%" route alias is deprecated. Do not use it anymore.'
1596+
1597+ .. code-block :: xml
1598+
1599+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1600+ <routes xmlns =" http://symfony.com/schema/routing"
1601+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1602+ xsi : schemaLocation =" http://symfony.com/schema/routing
1603+ https://symfony.com/schema/routing/routing-1.0.xsd" >
1604+
1605+ <route id =" new_route_name" alias =" original_route_name" >
1606+ <!-- this outputs the following generic deprecation message:
1607+ Since acme/package 1.2: The "new_route_name" route alias is deprecated. You should stop using it, as it will be removed in the future. -->
1608+ <deprecated package =" acme/package" version =" 1.2" />
1609+
1610+ <!-- you can also define a custom deprecation message (%alias_id% placeholder is available) -->
1611+ <deprecated package =" acme/package" version =" 1.2" >
1612+ The "%alias_id%" route alias is deprecated. Do not use it anymore.
1613+ </deprecated >
1614+ </route >
1615+ </routes >
1616+
1617+ .. code-block :: php
1618+
1619+ $routes->alias('new_route_name', 'original_route_name')
1620+ // this outputs the following generic deprecation message:
1621+ // Since acme/package 1.2: The "new_route_name" route alias is deprecated. You should stop using it, as it will be removed in the future.
1622+ ->deprecate('acme/package', '1.2', '')
1623+
1624+ // you can also define a custom deprecation message (%alias_id% placeholder is available)
1625+ ->deprecate(
1626+ 'acme/package',
1627+ '1.2',
1628+ 'The "%alias_id%" route alias is deprecated. Do not use it anymore.'
1629+ )
1630+ ;
1631+
1632+ In this example, every time the ``new_route_name `` alias is used, a deprecation
1633+ warning is triggered, advising you to stop using that alias.
1634+
1635+ The message is actually a message template, which replaces occurrences of the
1636+ ``%alias_id% `` placeholder by the route alias name. You **must ** have
1637+ at least one occurrence of the ``%alias_id% `` placeholder in your template.
1638+
15311639.. _routing-route-groups :
15321640
15331641Route Groups and Prefixes
@@ -1828,6 +1936,8 @@ Use the ``RedirectController`` to redirect to other routes and URLs:
18281936 # * for temporary redirects, it uses the 307 status code instead of 302
18291937 # * for permanent redirects, it uses the 308 status code instead of 301
18301938 keepRequestMethod : true
1939+ # add this to remove the original route attributes when redirecting
1940+ ignoreAttributes : true
18311941
18321942 legacy_doc :
18331943 path : /legacy/doc
0 commit comments