noartem

laravel-interfaces-and-di

1
0
# Install this skill:
npx skills add noartem/skills --skill "laravel-interfaces-and-di"

Install specific skill from multi-skill repository

# Description

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

# SKILL.md


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.

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.