# Laravel:strategy Pattern

> Use the Strategy pattern to select behavior at runtime; bind multiple implementations to a shared interface

- Skill: `jpcaparas/laravel-strategy-pattern` (Agent Skill)
- Install (CLI): `npx skillmds@latest add jpcaparas/laravel-strategy-pattern`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jpcaparas/laravel-strategy-pattern/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jpcaparas (https://skillmd.com/u/jpcaparas)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/jpcaparas/laravel-strategy-pattern

---


# Strategy Pattern

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

```php
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.


