laravel:strategy-pattern

Bind multiple strategy implementations behind a shared interface in Laravel.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/Patkik/Multi-tenant-SaaS-Catering-V2 --skill laravel-strategy-pattern-patkik
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel:strategy-pattern
Source: https://github.com/Patkik/Multi-tenant-SaaS-Catering-V2/tree/main/.agents/skills/strategy-pattern
Command: npx skills add https://github.com/Patkik/Multi-tenant-SaaS-Catering-V2 --skill laravel-strategy-pattern-patkik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Bind multiple strategy implementations behind a shared interface to enable runtime behavior selection and easier extension.

Core Features & Use Cases

  • Multiple strategy implementations share a common interface so you can swap behavior at runtime.
  • Factory-based resolution selects the appropriate strategy by context or key (e.g., country code).
  • Laravel integration wires the strategies via a service provider for dependency injection and reuse.

Quick Start

Register the strategies in the Laravel service container and resolve the appropriate strategy through a factory or context.

Frequently Asked Questions about laravel:strategy-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I switch runtime behavior in Laravel based on context?

Laravel strategy pattern swaps runtime behavior by binding concrete implementations behind a shared interface. A factory resolves the correct strategy by context key, enabling pluggable and extensible application logic.

How do I calculate tax by country using Laravel dependency injection?

Calculate tax by country using Laravel dependency injection by creating a Strategy interface, implementing country-specific concrete classes, and wiring them in a service provider. A factory resolves the correct strategy by country code at runtime.

What's the best way to implement feature toggles in a Laravel application?

The best way to implement feature toggles in Laravel is using the strategy pattern. Define a shared interface for toggle behavior, create concrete implementations, and use factory-based resolution to select the active strategy dynamically.

Do I need a service provider to wire strategy pattern implementations in Laravel?

Yes, a Laravel service provider is required to wire strategy implementations. It registers the shared interface, binds concrete strategies, and configures factory-based resolution to enable dependency injection for runtime behavior selection.

When should I use a factory to resolve pluggable strategies in Laravel?

Use a factory to resolve pluggable strategies in Laravel when your application requires context-driven policy decisions, such as tax calculation by country or feature toggles. Factories select the appropriate strategy implementation by a context key.