📋 Laravel Strategy Pattern

This skill enables runtime behavior selection using the Strategy pattern by binding multiple implementations to a shared interface across Laravel and Vue apps.

QUICK INSTALL
npx playbooks add skill noartem/skills --skill laravel-strategy-pattern

Laravel Strategy Pattern instructions

Strategy Pattern

Create a common interface and multiple implementations. Choose a strategy by key or context.

interface TaxCalculator { public function for(int $cents): int; }
final class NzTax implements TaxCalculator { /* ... */ }
final class AuTax implements TaxCalculator { /* ... */ }

final class TaxFactory {
  public function __construct(private array $drivers) {}
  public function forCountry(string $code): TaxCalculator { return $this->drivers[$code]; }
}

Register in a service provider and inject the factory where needed.

Related Skills

Get the best new skills
in your inbox

Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.