diff --git a/user_guide_src/source/incoming/routing.rst b/user_guide_src/source/incoming/routing.rst index a1bb81726b14..6a48e95fe7a2 100644 --- a/user_guide_src/source/incoming/routing.rst +++ b/user_guide_src/source/incoming/routing.rst @@ -543,6 +543,14 @@ with the name of the route: This has the added benefit of making the views more readable, too. +.. note:: By default, all defined routes have names matching their paths, with placeholders replaced by their corresponding + regular expressions. For example, if you define a route like ``$routes->get('edit/(:num)', 'PostController::edit/$1');``, + you can generate the corresponding URL using ``route_to('edit/([0-9]+)', 12)``. + +.. warning:: According to :ref:`routing-priority`, if a not-named route is defined first (e.g., ``$routes->get('edit', 'PostController::edit');``) + and another named route is defined later with the same name as the path of the first route (e.g., ``$routes->get('edit/(:num)', 'PostController::edit/$1', ['as' => 'edit']);``), + the second route will not be registered because its name will conflict with the automatically assigned name of the first route. + Grouping Routes ***************