Hej,
poniżej z dokumentacji Laravela
$this->app->bind(
'App\Contracts\EventPusher',
'App\Services\RedisEventPusher'
);
This statement tells the container that it should inject the RedisEventPusher when a class needs an implementation of EventPusher. Now we can type-hint the EventPusher interface in a constructor, or any other location where dependencies are injected by the service container.
W klasie, w której chce wstrzyknąć zależność przekazuję interfejs a nie jego konkretną implementację.
Dalej aby to "skonfigurować" należy w klasie dziedziczącej po ServiceProvider w metodzie register() ..... zbindować jak powyżej
Nie rozumiem co w przypadku gdy napiszę inną implementację tego interfejsu ? po prostu dodać kolejny bind? Nie rozumiem skąd Laravel wybierze implementację, której chce?
$this->app->bind(
'App\Contracts\EventPusher',
'App\Services\ZupelnieJakisTamHiperTorpedaEventPusher'
);
Moje pytanie