public function index(Request $request) { $controller = $request->route()->getController(); // $controller contains the name of current controller (e.g: UserController) ... }
public function index() { $controller = $this->uri->segment(1); // $controller contains the name of current controller (e.g: UserController) ... }Package Library: Laravel and CodeIgniter are PHP frameworks that have built-in support for MVC architecture, so getController method is included in their core library.