Skip to content

Commit 66ea8c0

Browse files
authored
Merge pull request #7573 from kenjis/fix-docs-routing.rst
docs: improve routing.rst
2 parents bfd952c + 59da173 commit 66ea8c0

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

user_guide_src/source/incoming/routing.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ If you expect a GET request, you use the ``get()`` method:
3131

3232
.. literalinclude:: routing/001.php
3333

34-
A route takes the URI path (``/``) on the left, and maps it to the controller and method (``Home::index``) on the right,
34+
A route takes the **Route Path** (URI path relative to the BaseURL. ``/``) on the left,
35+
and maps it to the **Route Handler** (controller and method ``Home::index``) on the right,
3536
along with any parameters that should be passed to the controller.
3637

3738
The controller and method should
@@ -320,22 +321,19 @@ define an array of routes and then pass it as the first parameter to the ``map()
320321
Command-Line Only Routes
321322
========================
322323

324+
.. note:: It is recommended to use Spark Commands for CLI scripts instead of calling controllers via CLI.
325+
See the :doc:`../cli/cli_commands` page for detailed information.
326+
323327
You can create routes that work only from the command-line, and are inaccessible from the web browser, with the
324328
``cli()`` method. Any route created by any of the HTTP-verb-based
325329
route methods will also be inaccessible from the CLI, but routes created by the ``add()`` method will still be
326330
available from the command line:
327331

328332
.. literalinclude:: routing/032.php
329333

330-
.. note:: It is recommended to use Spark Commands for CLI scripts instead of calling controllers via CLI.
331-
See the :doc:`../cli/cli_commands` page for detailed information.
332-
333334
.. warning:: If you enable :ref:`auto-routing-legacy` and place the command file in **app/Controllers**,
334335
anyone could access the command with the help of Auto Routing (Legacy) via HTTP.
335336

336-
.. note:: It is recommended to use Spark Commands instead of CLI routes.
337-
See the :doc:`../cli/spark_commands` page for detailed information.
338-
339337
Global Options
340338
**************
341339

@@ -537,7 +535,7 @@ Route Priority
537535

538536
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.
539537

540-
.. note:: If a route (the URI path) is defined more than once with different handlers, only the first defined route is registered.
538+
.. warning:: If a route path is defined more than once with different handlers, only the first defined route is registered.
541539

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

@@ -834,8 +832,8 @@ CodeIgniter has the following :doc:`command </cli/spark_commands>` to display al
834832

835833
.. _routing-spark-routes:
836834

837-
routes
838-
======
835+
spark routes
836+
============
839837

840838
Displays all routes and filters::
841839

@@ -854,9 +852,9 @@ The output is like the following:
854852
855853
The *Method* column shows the HTTP method that the route is listening for.
856854

857-
The *Route* column shows the route (URI path) to match. The route of a defined route is expressed as a regular expression.
855+
The *Route* column shows the route path to match. The route of a defined route is expressed as a regular expression.
858856

859-
Since v4.3.0, the *Name* column shows the route name. ``»`` indicates the name is the same as the route.
857+
Since v4.3.0, the *Name* column shows the route name. ``»`` indicates the name is the same as the route path.
860858

861859
.. important:: The system is not perfect. If you use Custom Placeholders, *Filters* might not be correct. If you want to check filters for a route, you can use :ref:`spark filter:check <spark-filter-check>` command.
862860

@@ -877,6 +875,8 @@ The *Method* will be like ``GET(auto)``.
877875

878876
``/..`` in the *Route* column indicates one segment. ``[/..]`` indicates it is optional.
879877

878+
.. note:: When auto-routing is enabled and you have the route ``home``, it can be also accessed by ``Home``, or maybe by ``hOme``, ``hoMe``, ``HOME``, etc. but the command will show only ``home``.
879+
880880
If you see a route starting with ``x`` like the following, it indicates an invalid
881881
route that won't be routed, but the controller has a public method for routing.
882882

@@ -913,7 +913,7 @@ The *Method* will be ``auto``.
913913

914914
``[/...]`` in the *Route* column indicates any number of segments.
915915

916-
.. note:: When auto-routing is enabled, if you have the route ``home``, it can be also accessd by ``Home``, or maybe by ``hOme``, ``hoMe``, ``HOME``, etc. But the command shows only ``home``.
916+
.. note:: When auto-routing is enabled and you have the route ``home``, it can be also accessed by ``Home``, or maybe by ``hOme``, ``hoMe``, ``HOME``, etc. but the command will show only ``home``.
917917

918918
.. _routing-spark-routes-sort-by-handler:
919919

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
$routes->get('product/(:any)', 'Catalog::productLookup');
3+
$routes->get('product/(:segment)', 'Catalog::productLookup');

0 commit comments

Comments
 (0)