@@ -756,21 +756,22 @@ See :ref:`Auto Routing in Controllers <controller-auto-routing-improved>` for mo
756
756
Configuration Options
757
757
=====================
758
758
759
- These options are available at the top of **app/Config/Routes .php **.
759
+ These options are available in the **app/Config/Routing .php ** file .
760
760
761
761
Default Controller
762
762
------------------
763
763
764
764
For Site Root URI
765
765
^^^^^^^^^^^^^^^^^
766
766
767
- When a user visits the root of your site (i.e., **example.com **) the controller to use is determined by the value set by
768
- the ``setDefaultController() `` method, unless a route exists for it explicitly.
767
+ When a user visits the root of your site (i.e., **example.com **) the controller
768
+ to use is determined by the value set to the ``$defaultController `` property,
769
+ unless a route exists for it explicitly.
769
770
770
- The default value for this is ``Home ``
771
- which matches the controller at **app/Controllers/Home.php **:
771
+ The default value for this is ``Home `` which matches the controller at
772
+ **app/Controllers/Home.php **: :
772
773
773
- .. literalinclude :: routing/047.php
774
+ public string $defaultController = 'Home';
774
775
775
776
For Directory URI
776
777
^^^^^^^^^^^^^^^^^
@@ -791,10 +792,10 @@ This works similar to the default controller setting, but is used to determine t
791
792
when a controller is found that matches the URI, but no segment exists for the method. The default value is
792
793
``index ``.
793
794
794
- In this example, if the user were to visit **example.com/products **, and a ``Products `` controller existed, the
795
- ``Products::getListAll() `` method would be executed:
795
+ In this example, if the user were to visit **example.com/products **, and a ``Products ``
796
+ controller existed, the ``Products::getListAll() `` method would be executed: :
796
797
797
- .. literalinclude :: routing/048.php
798
+ public string $defaultMethod = 'listAll';
798
799
799
800
.. important :: You cannot access the controller with the URI of the default method name.
800
801
In the example above, you can access **example.com/products **, but if you access **example.com/products/listall **, it will be not found.
@@ -884,19 +885,22 @@ See :ref:`Auto Routing (Legacy) in Controllers <controller-auto-routing-legacy>`
884
885
Configuration Options (Legacy)
885
886
==============================
886
887
887
- These options are available at the top of **app/Config/Routes .php **.
888
+ These options are available in the **app/Config/Routing .php ** file .
888
889
889
890
Default Controller (Legacy)
890
891
---------------------------
891
892
892
893
For Site Root URI (Legacy)
893
894
^^^^^^^^^^^^^^^^^^^^^^^^^^
894
895
895
- When a user visits the root of your site (i.e., example.com) the controller to use is determined by the value set by
896
- the `` setDefaultController() `` method, unless a route exists for it explicitly. The default value for this is ``Home ``
897
- which matches the controller at ** app/Controllers/Home.php **:
896
+ When a user visits the root of your site (i.e., ** example.com ** ) the controller
897
+ to use is determined by the value set to the ``$defaultController `` property,
898
+ unless a route exists for it explicitly.
898
899
899
- .. literalinclude :: routing/047.php
900
+ The default value for this is ``Home `` which matches the controller at
901
+ **app/Controllers/Home.php **::
902
+
903
+ public string $defaultController = 'Home';
900
904
901
905
For Directory URI (Legacy)
902
906
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -914,10 +918,10 @@ This works similar to the default controller setting, but is used to determine t
914
918
when a controller is found that matches the URI, but no segment exists for the method. The default value is
915
919
``index ``.
916
920
917
- In this example, if the user were to visit **example.com/products **, and a ``Products `` controller existed, the
918
- ``Products::listAll() `` method would be executed:
921
+ In this example, if the user were to visit **example.com/products **, and a ``Products ``
922
+ controller existed, the ``Products::listAll() `` method would be executed: :
919
923
920
- .. literalinclude :: routing/048.php
924
+ public string $defaultMethod = 'listAll';
921
925
922
926
Confirming Routes
923
927
*****************
0 commit comments