Call from view:
<?php echo Yii::$app->controller->id; //the name of the current controller //Yii::$app->controller get a controller as an object echo Yii::$app->controller->action->id; //name of the current action echo Yii::$app->controller->module->id; //the name of the current module
Call from controller:
<?php echo $this->id; //the name of the current controller echo $this->action->id; //name of the current action echo $this->module->id; //the name of the current module