【问题标题】:getting error when i work on repo in laravel [closed]当我在 laravel 中处理 repo 时出错 [关闭]
【发布时间】:2019-10-18 22:06:26
【问题描述】:

Illuminate\Contracts\Container\BindingResolutionException 目标 [App\Repositories\FaultTypes\FaultTypesInterface] 不可实例化 在构建 [App\Http\Controllers\FaultTypesController 时, App\Services\FaultTypesService]。

【问题讨论】:

  • 请在我创建存储库并使用时帮助我,然后给我错误。并且是[“目标 [App\Repositories\FaultTypes\FaultTypesInterface] 在构建 [App\Http\Controllers\FaultTypesController, App\Services\FaultTypesS ▶”时不可实例化]
  • 您可以将您的代码添加到问题中吗?你能解释一下你到底想做什么吗?你想达到什么目标?

标签: php laravel


【解决方案1】:

你的控制器中可能有这样的东西

public function __construct(FaultTypesInterface $faultTypes) {
...
}

问题是 Laravel 的服务容器不知道如何实例化这样的接口

您可以通过声明此绑定来解决此问题。所以在app/providers/AppServiceProvider.phpregister() 方法中你可以写这样的东西

app()->bind('App\Repositories\FaultTypes\FaultTypesInterface', 'Path\To\Your\Concrete\Class');

【讨论】:

  • 同样的问题再次出现
  • 很抱歉,根据您提供的信息,这是我能提供的最佳帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-11-15
  • 2013-01-02
  • 2020-06-15
  • 1970-01-01
  • 2020-08-03
  • 2021-05-21
  • 1970-01-01
相关资源
最近更新 更多