Skip to content

Commit a24e4b6

Browse files
committed
docs: add explanation for namespacing
1 parent 019ebea commit a24e4b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

user_guide_src/source/incoming/routing.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ 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,
89+
if a controller name is stated without beginning with ``\``, the :ref:`routing-default-namespace` will be prepended:
8990

9091
.. literalinclude:: routing/063.php
9192

@@ -114,6 +115,14 @@ Or using ``use`` keyword:
114115
.. literalinclude:: routing/014.php
115116
:lines: 2-
116117

118+
If you forget ``use App\Controllers\Home;``, the controller classname is interpreted
119+
as ``Config\Home``, not ``App\Controllers\Home`` because **app/Config/Routes.php**
120+
has ``namespace Config;`` at the top.
121+
122+
.. note:: When you use Array Callable Syntax, the classname is always interpreted
123+
as a fully qualified classname. So :ref:`routing-default-namespace` and
124+
:ref:`namespace option <assigning-namespace>` have no effect.
125+
117126
Array Callable Syntax and Placeholders
118127
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119128

0 commit comments

Comments
 (0)