Skip to content

Commit f81dd1a

Browse files
authored
Merge pull request #8329 from kenjis/docs-update-routing
docs: update sample code in Auto Routing
2 parents 3d742a3 + 5c4c72c commit f81dd1a

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

user_guide_src/source/incoming/routing.rst

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -740,21 +740,22 @@ See :ref:`Auto Routing in Controllers <controller-auto-routing-improved>` for mo
740740
Configuration Options
741741
=====================
742742

743-
These options are available at the top of **app/Config/Routes.php**.
743+
These options are available in the **app/Config/Routing.php** file.
744744

745745
Default Controller
746746
------------------
747747

748748
For Site Root URI
749749
^^^^^^^^^^^^^^^^^
750750

751-
When a user visits the root of your site (i.e., **example.com**) the controller to use is determined by the value set by
752-
the ``setDefaultController()`` method, unless a route exists for it explicitly.
751+
When a user visits the root of your site (i.e., **example.com**) the controller
752+
to use is determined by the value set to the ``$defaultController`` property,
753+
unless a route exists for it explicitly.
753754

754-
The default value for this is ``Home``
755-
which matches the controller at **app/Controllers/Home.php**:
755+
The default value for this is ``Home`` which matches the controller at
756+
**app/Controllers/Home.php**::
756757

757-
.. literalinclude:: routing/047.php
758+
public string $defaultController = 'Home';
758759

759760
For Directory URI
760761
^^^^^^^^^^^^^^^^^
@@ -775,10 +776,10 @@ This works similar to the default controller setting, but is used to determine t
775776
when a controller is found that matches the URI, but no segment exists for the method. The default value is
776777
``index``.
777778

778-
In this example, if the user were to visit **example.com/products**, and a ``Products`` controller existed, the
779-
``Products::getListAll()`` method would be executed:
779+
In this example, if the user were to visit **example.com/products**, and a ``Products``
780+
controller existed, the ``Products::getListAll()`` method would be executed::
780781

781-
.. literalinclude:: routing/048.php
782+
public string $defaultMethod = 'listAll';
782783

783784
.. important:: You cannot access the controller with the URI of the default method name.
784785
In the example above, you can access **example.com/products**, but if you access **example.com/products/listall**, it will be not found.
@@ -868,19 +869,22 @@ See :ref:`Auto Routing (Legacy) in Controllers <controller-auto-routing-legacy>`
868869
Configuration Options (Legacy)
869870
==============================
870871

871-
These options are available at the top of **app/Config/Routes.php**.
872+
These options are available in the **app/Config/Routing.php** file.
872873

873874
Default Controller (Legacy)
874875
---------------------------
875876

876877
For Site Root URI (Legacy)
877878
^^^^^^^^^^^^^^^^^^^^^^^^^^
878879

879-
When a user visits the root of your site (i.e., example.com) the controller to use is determined by the value set by
880-
the ``setDefaultController()`` method, unless a route exists for it explicitly. The default value for this is ``Home``
881-
which matches the controller at **app/Controllers/Home.php**:
880+
When a user visits the root of your site (i.e., **example.com**) the controller
881+
to use is determined by the value set to the ``$defaultController`` property,
882+
unless a route exists for it explicitly.
882883

883-
.. literalinclude:: routing/047.php
884+
The default value for this is ``Home`` which matches the controller at
885+
**app/Controllers/Home.php**::
886+
887+
public string $defaultController = 'Home';
884888

885889
For Directory URI (Legacy)
886890
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -898,10 +902,10 @@ This works similar to the default controller setting, but is used to determine t
898902
when a controller is found that matches the URI, but no segment exists for the method. The default value is
899903
``index``.
900904

901-
In this example, if the user were to visit **example.com/products**, and a ``Products`` controller existed, the
902-
``Products::listAll()`` method would be executed:
905+
In this example, if the user were to visit **example.com/products**, and a ``Products``
906+
controller existed, the ``Products::listAll()`` method would be executed::
903907

904-
.. literalinclude:: routing/048.php
908+
public string $defaultMethod = 'listAll';
905909

906910
Confirming Routes
907911
*****************

user_guide_src/source/incoming/routing/047.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

user_guide_src/source/incoming/routing/048.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)