Define narrow interfaces and inject them where needed. Bind concrete implementations in a service provider. ```php 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.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Laravel Interfaces And Di?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/comeonoliver-laravel-interfaces-and-di)
# Interfaces and Dependency Injection
Define narrow interfaces and inject them where needed. Bind concrete implementations in a service provider.
```php
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.