admin管理员组文章数量:1287153
I am trying to configure container. here is my config/web.php where i configured container.
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'language' => 'ru-RU',
'bootstrap' => ['log'],
'container' => [
'definitions' => [],
'singletons' => [
\core\repositories\UserRepositoryInterface::class => \core\repositories\UserRepository::class
]
],
then i am trying to inject dependency here
namespace app\controllers;
use app\models\LoginForm;
use app\models\User;
use core\repositories\UserRepositoryInterface;
use Yii;
class SiteController extends \yii\web\Controller
{
private UserRepositoryInterface $repository;
public function __construct(
$id,
$module,
UserRepositoryInterface $repository,
$config = [])
{
parent::__construct($id, $module, $config);
$this->repository = $repository;
}
So i'am getting error
Not instantiable – yii\di\NotInstantiableException
Failed to instantiate component or class "core\repositories\UserRepository".
↵
Caused by: ReflectionException
Class "core\repositories\UserRepository" does not exist
本文标签: dependency injectionYii2 DI container can39t instantiate my classStack Overflow
版权声明:本文标题:dependency injection - Yii2 DI container can't instantiate my class - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741307361a2371449.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论