@@ -1343,8 +1343,12 @@ Route alias allow you to have multiple name for the same route:
1343
1343
.. code-block :: yaml
1344
1344
1345
1345
# config/routes.yaml
1346
- new_route_name :
1347
- alias : original_route_name
1346
+ some_route_name :
1347
+ path : /some-path
1348
+ controller : App\Controller\SomeController::index
1349
+
1350
+ alias_to_some_route_name :
1351
+ alias : some_route_name # refers to the name of the route declared above
1348
1352
1349
1353
.. code-block :: xml
1350
1354
@@ -1355,7 +1359,9 @@ Route alias allow you to have multiple name for the same route:
1355
1359
xsi : schemaLocation =" http://symfony.com/schema/routing
1356
1360
https://symfony.com/schema/routing/routing-1.0.xsd" >
1357
1361
1358
- <route id =" new_route_name" alias =" original_route_name" />
1362
+ <route id =" some_route_name" path =" /some-path" controller =" App\Controller\SomeController::index" />
1363
+ <!-- "alias" attribute value refers to the name of the route declared above -->
1364
+ <route id =" alias_to_some_route_name" alias =" some_route_name" />
1359
1365
</routes >
1360
1366
1361
1367
.. code-block :: php
@@ -1364,10 +1370,13 @@ Route alias allow you to have multiple name for the same route:
1364
1370
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
1365
1371
1366
1372
return static function (RoutingConfigurator $routes): void {
1367
- $routes->alias('new_route_name', 'original_route_name');
1373
+ $routes->add('some_route_name', '/some_route_path')
1374
+ ->controller('App\Controller\SomeController::index');
1375
+ // second argument refers to the name of the route declared above
1376
+ $routes->alias('alias_to_some_route_name', 'some_route_name');
1368
1377
};
1369
1378
1370
- In this example, both ``original_route_name `` and ``new_route_name `` routes can
1379
+ In this example, both ``some_route_name `` and ``alias_to_some_route_name `` routes can
1371
1380
be used in the application and will produce the same result.
1372
1381
1373
1382
.. _routing-alias-deprecation :
@@ -1382,11 +1391,15 @@ you decided not to maintain it anymore), you can deprecate its definition:
1382
1391
1383
1392
.. code-block :: yaml
1384
1393
1385
- new_route_name :
1386
- alias : original_route_name
1394
+ some_route_name :
1395
+ path : /some-path
1396
+ controller : App\Controller\SomeController::index
1397
+
1398
+ alias_to_some_route_name :
1399
+ alias : some_route_name # refers to the name of the route declared above
1387
1400
1388
1401
# this outputs the following generic deprecation message:
1389
- # 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.
1402
+ # Since acme/package 1.2: The "alias_to_some_route_name " route alias is deprecated. You should stop using it, as it will be removed in the future.
1390
1403
deprecated :
1391
1404
package : ' acme/package'
1392
1405
version : ' 1.2'
@@ -1405,9 +1418,11 @@ you decided not to maintain it anymore), you can deprecate its definition:
1405
1418
xsi : schemaLocation =" http://symfony.com/schema/routing
1406
1419
https://symfony.com/schema/routing/routing-1.0.xsd" >
1407
1420
1408
- <route id =" new_route_name" alias =" original_route_name" >
1421
+ <route id =" some_route_name" path =" /some-path" controller =" App\Controller\SomeController::index" />
1422
+ <!-- "alias" attribute value refers to the name of the route declared above -->
1423
+ <route id =" alias_to_some_route_name" alias =" some_route_name" >
1409
1424
<!-- this outputs the following generic deprecation message:
1410
- 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. -->
1425
+ Since acme/package 1.2: The "alias_to_some_route_name " route alias is deprecated. You should stop using it, as it will be removed in the future. -->
1411
1426
<deprecated package =" acme/package" version =" 1.2" />
1412
1427
1413
1428
<!-- you can also define a custom deprecation message (%alias_id% placeholder is available) -->
@@ -1419,9 +1434,12 @@ you decided not to maintain it anymore), you can deprecate its definition:
1419
1434
1420
1435
.. code-block :: php
1421
1436
1422
- $routes->alias('new_route_name', 'original_route_name')
1437
+ $routes->add('some_route_name', '/some_route_path')
1438
+ ->controller('App\Controller\SomeController::index');
1439
+ // second argument refers to the name of the route declared above
1440
+ $routes->alias('alias_to_some_route_name', 'some_route_name');
1423
1441
// this outputs the following generic deprecation message:
1424
- // 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.
1442
+ // Since acme/package 1.2: The "alias_to_some_route_name " route alias is deprecated. You should stop using it, as it will be removed in the future.
1425
1443
->deprecate('acme/package', '1.2', '')
1426
1444
1427
1445
// you can also define a custom deprecation message (%alias_id% placeholder is available)
@@ -1432,7 +1450,7 @@ you decided not to maintain it anymore), you can deprecate its definition:
1432
1450
)
1433
1451
;
1434
1452
1435
- In this example, every time the ``new_route_name `` alias is used, a deprecation
1453
+ In this example, every time the ``alias_to_some_route_name `` alias is used, a deprecation
1436
1454
warning is triggered, advising you to stop using that alias.
1437
1455
1438
1456
The message is actually a message template, which replaces occurrences of the
0 commit comments