Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get current controller in yii2

Tags:

I'm trying to get current page controller in yii2? How can I achieve this in Yii2?

In Yii 1.0

Yii::app()->controller->action->id 

Yii2 ?

like image 238
rdanusha Avatar asked Jan 06 '15 10:01

rdanusha


People also ask

What is controller in yii2?

CController manages a set of actions which deal with the corresponding user requests. Through the actions, CController coordinates the data flow between models and views.


1 Answers

use this code

Yii::$app->controller->id 
like image 105
Ranidu Avatar answered Sep 22 '22 00:09

Ranidu