Skip to content

docs: add about route priority #6391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions user_guide_src/source/incoming/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,17 @@ be used when the first parameter is a language string:

.. _routing-priority:

Route processing queue
----------------------
Route Priority
**************

Routes are registered in the routing table in the order in which they are defined. This means that when a URI is accessed, the first matching route will be executed.

.. note:: If a route (the URI path) is defined more than once with different handlers, only the first defined route is registered.

You can check registered routes in the routing table by running the :ref:`spark routes <spark-routes>` command.

Changing Route Priority
=======================

When working with modules, it can be a problem if the routes in the application contain wildcards.
Then the module routes will not be processed correctly.
Expand Down Expand Up @@ -528,7 +537,7 @@ a valid class/method pair, just like you would show in any route, or a Closure:
will be returned. See :php:func:`Response::setStatusCode() <setStatusCode>` for
information on how to set the status code.

Route processing by priority
Route Processing by Priority
============================

Enables or disables processing of the routes queue by priority. Lowering the priority is defined in the route option.
Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/incoming/routing/043.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

// First you need to enable sorting.
// First you need to enable processing of the routes queue by priority.
$routes->setPrioritize();

// Config\Routes
Expand All @@ -9,4 +9,4 @@
// Modules\Acme\Config\Routes
$routes->get('admin', 'Admin::index');

// The "admin" route will now be processed before the wildcard router.
// The "admin" route will now be processed before the wildcard route.