Get Name of Current Controller and Action in Yii
By Nick Holdren | December 5, 2011
This is a simple one line piece of code to retrieve the name of the current controller, which is great for making more generic and useful code.
$controllerName = Yii::app()->controller->id;



2 Comments
shahid on December 7, 2011 at 9:39 am.
wrong. use this “$this->getId()”. Done!
Nick Holdren on December 7, 2011 at 12:02 pm.
Agreed, that works as well but only in the context of the controller class. My example should work throughout the application.