문제 설명
yii2 컨트롤러 작업 주입은 어떻게 작동합니까? (How does the yii2 Controller action injection works)
저는 yii2의 종속성 주입에 대해 작업 중이며 매우 유용한 주제인 컨트롤러 작업 주입. 시도했지만 작동하지 않습니다. 나는 모든 Google 작업을 수행했고 이벤트는 yii2 프레임워크의 소스 코드를 읽었습니다. 제가 놓치고 있는 것이 있습니까? 내 코드는 다음과 같습니다.
//my action
public function actionIndex(JobService $jobService) {
//logic code
}
//i register the dependencies in the bootstrap file
// and yes ,i tried \Yii::$container‑>set('JobService', '\hr\services\JobService') too
\Yii::$container‑>set('\hr\services\JobService', '\hr\services\JobService');
참조 솔루션
방법 1:
the controller DI just fixed two month ago, and they hadn't release yet, you can fix it manually. check you yii\web\Controller with github‑yii\web\Controller