I am working on the Dependency Injection of yii2 and I find some really useful topic,the Controller action injection . I tried, but it just does not work. I have done all the google thing and event read the source code of the yii2 framework, am I missing something? Here is my code:
//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');
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.