Skip to content

Commit 49dabc1

Browse files
authored
Merge pull request #7560 from kenjis/fix-docs-routing.rst
docs: improve Array Callable Syntax explanation in routing.rst
2 parents 7a394d2 + f6bcb65 commit 49dabc1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

user_guide_src/source/incoming/routing.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ Specifying Route Handlers
8585
Controller's Namespace
8686
----------------------
8787

88-
If a controller name is stated without beginning with ``\``, the :ref:`routing-default-namespace` will be prepended:
88+
When you specify a controller and method name as a string, if a controller is
89+
written without a leading ``\``, the :ref:`routing-default-namespace` will be
90+
prepended:
8991

9092
.. literalinclude:: routing/063.php
9193

@@ -114,6 +116,17 @@ Or using ``use`` keyword:
114116
.. literalinclude:: routing/014.php
115117
:lines: 2-
116118

119+
If you forget to add ``use App\Controllers\Home;``, the controller classname is
120+
interpreted as ``Config\Home``, not ``App\Controllers\Home`` because
121+
**app/Config/Routes.php** has ``namespace Config;`` at the top.
122+
123+
.. note:: When you use Array Callable Syntax, the classname is always interpreted
124+
as a fully qualified classname. So :ref:`routing-default-namespace` and
125+
:ref:`namespace option <assigning-namespace>` have no effect.
126+
127+
Array Callable Syntax and Placeholders
128+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129+
117130
If there are placeholders, it will automatically set the parameters in the specified order:
118131

119132
.. literalinclude:: routing/015.php

0 commit comments

Comments
 (0)