You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/incoming/routing.rst
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -151,6 +151,18 @@ a simple view:
151
151
152
152
.. literalinclude:: routing/020.php
153
153
154
+
Retrieving the Controller and Method Names
155
+
------------------------------------------
156
+
157
+
In some cases, you might need to determine which controller and method have been triggered by the current HTTP request.
158
+
This can be useful for logging, debugging, or conditional logic based on the active controller method.
159
+
160
+
CodeIgniter 4 provides a simple way to access the current route's controller and method names using the ``Services::router()`` class. Here is an example:
161
+
162
+
.. literalinclude:: routing/071.php
163
+
164
+
This functionality is particularly useful when you need to dynamically interact with your controller or log which method is handling a particular request.
0 commit comments