Skip to content

Commit 3eaecb6

Browse files
committed
docs: level up "Grouping Routes"
1 parent 8fa52ed commit 3eaecb6

1 file changed

Lines changed: 51 additions & 51 deletions

File tree

user_guide_src/source/incoming/routing.rst

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -258,57 +258,6 @@ redirect and is recommended in most cases:
258258
If a redirect route is matched during a page load, the user will be immediately redirected to the new page before a
259259
controller can be loaded.
260260

261-
Grouping Routes
262-
===============
263-
264-
You can group your routes under a common name with the ``group()`` method. The group name becomes a segment that
265-
appears prior to the routes defined inside of the group. This allows you to reduce the typing needed to build out an
266-
extensive set of routes that all share the opening string, like when building an admin area:
267-
268-
.. literalinclude:: routing/023.php
269-
270-
This would prefix the **users** and **blog** URIs with **admin**, handling URLs like **admin/users** and **admin/blog**.
271-
272-
Setting Namespace
273-
-----------------
274-
275-
If you need to assign options to a group, like a :ref:`assigning-namespace`, do it before the callback:
276-
277-
.. literalinclude:: routing/024.php
278-
279-
This would handle a resource route to the ``App\API\v1\Users`` controller with the **api/users** URI.
280-
281-
Setting Filters
282-
---------------
283-
284-
You can also use a specific :doc:`filter <filters>` for a group of routes. This will always
285-
run the filter before or after the controller. This is especially handy during authentication or api logging:
286-
287-
.. literalinclude:: routing/025.php
288-
289-
The value for the filter must match one of the aliases defined within **app/Config/Filters.php**.
290-
291-
Setting Other Options
292-
---------------------
293-
294-
At some point, you may want to group routes for the purpose of applying filters or other route
295-
config options like namespace, subdomain, etc. Without necessarily needing to add a prefix to the group, you can pass
296-
an empty string in place of the prefix and the routes in the group will be routed as though the group never existed but with the
297-
given route config options:
298-
299-
.. literalinclude:: routing/027.php
300-
301-
Nesting Groups
302-
--------------
303-
304-
It is possible to nest groups within groups for finer organization if you need it:
305-
306-
.. literalinclude:: routing/026.php
307-
308-
This would handle the URL at **admin/users/list**.
309-
310-
.. note:: Options passed to the outer ``group()`` (for example ``namespace`` and ``filter``) are not merged with the inner ``group()`` options.
311-
312261
Environment Restrictions
313262
========================
314263

@@ -512,6 +461,57 @@ be used when the first parameter is a language string:
512461

513462
.. literalinclude:: routing/042.php
514463

464+
Grouping Routes
465+
***************
466+
467+
You can group your routes under a common name with the ``group()`` method. The group name becomes a segment that
468+
appears prior to the routes defined inside of the group. This allows you to reduce the typing needed to build out an
469+
extensive set of routes that all share the opening string, like when building an admin area:
470+
471+
.. literalinclude:: routing/023.php
472+
473+
This would prefix the **users** and **blog** URIs with **admin**, handling URLs like **admin/users** and **admin/blog**.
474+
475+
Setting Namespace
476+
=================
477+
478+
If you need to assign options to a group, like a :ref:`assigning-namespace`, do it before the callback:
479+
480+
.. literalinclude:: routing/024.php
481+
482+
This would handle a resource route to the ``App\API\v1\Users`` controller with the **api/users** URI.
483+
484+
Setting Filters
485+
===============
486+
487+
You can also use a specific :doc:`filter <filters>` for a group of routes. This will always
488+
run the filter before or after the controller. This is especially handy during authentication or api logging:
489+
490+
.. literalinclude:: routing/025.php
491+
492+
The value for the filter must match one of the aliases defined within **app/Config/Filters.php**.
493+
494+
Setting Other Options
495+
=====================
496+
497+
At some point, you may want to group routes for the purpose of applying filters or other route
498+
config options like namespace, subdomain, etc. Without necessarily needing to add a prefix to the group, you can pass
499+
an empty string in place of the prefix and the routes in the group will be routed as though the group never existed but with the
500+
given route config options:
501+
502+
.. literalinclude:: routing/027.php
503+
504+
Nesting Groups
505+
==============
506+
507+
It is possible to nest groups within groups for finer organization if you need it:
508+
509+
.. literalinclude:: routing/026.php
510+
511+
This would handle the URL at **admin/users/list**.
512+
513+
.. note:: Options passed to the outer ``group()`` (for example ``namespace`` and ``filter``) are not merged with the inner ``group()`` options.
514+
515515
.. _routing-priority:
516516

517517
Route Priority

0 commit comments

Comments
 (0)