在 控制器 或视图里面: $controllerID = \Yii::$app->controller->id; $actionID = \Yii::$app->controller->action->id;