andersao / andersao/l5-repository

Interface not instantiable while building class (Model observer)

オープン
#724 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
PHP
スター
4.2k
フォーク
880
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi,

I'm using a Model observer to create related entries on the Model's `created` event. I'm using this repository package to communicate with my database. I bind the RepositoryInterfaces to their concrete classes in my `RepositoryServiceProvider`, which I added to the `'providers'` array in my `config/app.php`. When my Observer runs, however, I get the following error:

```
Target [App\Repositories\Interfaces\ExamAttemptQuestionRepositoryInterface] is not instantiable while building [App\Observers\ExamAttemptObserver].
```
I've created a little test interface `MyInterface`, implemented it in `MyClass` and bound the interface to the implementation in my `RepositoryServiceProvider`, just like I did with all my other repositories. The observer doesn't throw an exception when I resolve `MyInterface` in the constructor.
```
interface MyInterface
{
public function test(): string;
}
```

I've raised an issue on [Laracasts](https://laracasts.com/discuss/channels/laravel/interface-not-instantiable-in-model-observer), but was hoping to also get help from here, since I'm unsure if where the issue originates.

Kinds regards,

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。