From 16f9880d73e965d46fa1e4f3fc869c48bcf9e09e Mon Sep 17 00:00:00 2001 From: Ilia Chernykh <25124661+Elias-Black@users.noreply.github.com> Date: Mon, 7 Apr 2025 00:24:56 +0500 Subject: [PATCH] docs: Add description of conflicts between named and unnamed routes --- user_guide_src/source/incoming/routing.rst | 8 ++++++++ 1 file changed, 8 insertions(+) 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 ***************