Skip to content

Commit 92d69b4

Browse files
authored
docs: Add description of conflicts between named and unnamed routes (#9499)
1 parent d33327c commit 92d69b4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

user_guide_src/source/incoming/routing.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,14 @@ with the name of the route:
543543

544544
This has the added benefit of making the views more readable, too.
545545

546+
.. note:: By default, all defined routes have names matching their paths, with placeholders replaced by their corresponding
547+
regular expressions. For example, if you define a route like ``$routes->get('edit/(:num)', 'PostController::edit/$1');``,
548+
you can generate the corresponding URL using ``route_to('edit/([0-9]+)', 12)``.
549+
550+
.. warning:: According to :ref:`routing-priority`, if a not-named route is defined first (e.g., ``$routes->get('edit', 'PostController::edit');``)
551+
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']);``),
552+
the second route will not be registered because its name will conflict with the automatically assigned name of the first route.
553+
546554
Grouping Routes
547555
***************
548556

0 commit comments

Comments
 (0)