laravel-interfaces-and-di

star 136

Use interfaces and dependency injection to decouple code; bind implementations in the container

jpcaparas By jpcaparas schedule Updated 11/3/2025

name: laravel:interfaces-and-di description: Use interfaces and dependency injection to decouple code; bind implementations in the container

Interfaces and Dependency Injection

Define narrow interfaces and inject them where needed. Bind concrete implementations in a service provider.

interface Slugger { public function slug(string $s): string; }

final class AsciiSlugger implements Slugger {
  public function slug(string $s): string { /* ... */ }
}

$this->app->bind(Slugger::class, AsciiSlugger::class);

Benefits: easier testing (mock interfaces), clearer contracts, swap implementations without touching consumers.

Install via CLI
npx skills add https://github.com/jpcaparas/superpowers-laravel --skill laravel-interfaces-and-di
Repository Details
star Stars 136
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator