About laravel:interfaces-and-di
A Laravel development skill on defining narrow interfaces, injecting them where needed, and binding implementations in a service provider to support testing and implementation swaps.
Key features
- 01Define narrow interfaces
- 02Inject interfaces where needed
- 03Bind implementations in service providers
- 04Mock interfaces for tests
- 05Swap concrete implementations
Use cases
- 01Define clear contracts for business logic
- 02Mock dependencies in tests
- 03Replace an interface implementation
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ jpcaparas/ superpowers-laravel --skill laravel:interfaces-and-diAfter installing, type/laravel:interfaces-and-diin Claude Code to confirm it loaded.
Details
From the project READMEInterfaces 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.
Comments
Markdown supported