Skip to content

Commit d8953ad

Browse files
committed
docs: add e.g. for Retrieving the Controller and Method Names
1 parent a969827 commit d8953ad

File tree

1 file changed

+15
-0
lines changed
  • user_guide_src/source/incoming/routing

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Config\Services;
4+
5+
// Get the router instance
6+
$router = Services::router();
7+
8+
// Retrieve the fully qualified class name of the controller handling the current request.
9+
$controller = $router->controllerName();
10+
11+
// Retrieve the method name being executed in the controller for the current request.
12+
$method = $router->methodName();
13+
14+
echo "Current Controller: " . $controller . "<br>";
15+
echo "Current Method: " . $method;

0 commit comments

Comments
 (0)