gpt4 book ai didi

php - yii2 Controller Action 注入(inject)是如何工作的

转载 作者:搜寻专家 更新时间:2023-10-31 21:27:31 24 4
gpt4 key购买 nike

我正在研究 yii2 的依赖注入(inject),我发现了一些非常有用的话题,Controller action injection .我试过了,但就是行不通。我已经完成了所有谷歌的事情和事件阅读了 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');

我收到以下错误消息: enter image description here

最佳答案

controller DI两个月前刚修好,还没发布,可以手动修一下。用 github-yii\web\Controller 检查你的 yii\web\Controller

关于php - yii2 Controller Action 注入(inject)是如何工作的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33993910/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com