重写Controller类的`beforeAction`方法即可 ```php public function beforeAction($action) { var_dump(Yii::$app->controller->id); var_dump(Yii::$app->controller->action->id); return parent::beforeAction($action); } ```