Developers can get the controller name in Yii2 throigh this method -

//Controller Name
echo Yii::$app->controller->id;

We can also get current action through this method:
echo Yii::$app->controller->action->id;

BY Best Interview Question ON 01 Feb 2019