symfonystrategy-pattern
Implement the Strategy pattern with Symfony's tagged services for runtime algorithm selection and extensibility
When & Why to Use This Skill
This Claude skill streamlines the implementation of the Strategy design pattern within Symfony applications by leveraging tagged services. It enables developers to build highly extensible and decoupled systems where specific algorithms or behaviors can be selected at runtime, ensuring adherence to SOLID principles and improving long-term code maintainability.
Use Cases
- Scenario 1: Implementing multiple payment gateways (e.g., Stripe, PayPal, Adyen) where the system dynamically selects the correct processing logic based on the user's choice at checkout.
- Scenario 2: Creating a flexible file export system that switches between PDF, Excel, and CSV strategies based on the requested file extension.
- Scenario 3: Developing a notification engine that routes messages through different channels like Email, SMS, or Push Notifications depending on user preferences and priority.
- Scenario 4: Refactoring large, complex 'if-else' or 'switch' blocks into discrete strategy classes to improve unit testing and simplify the addition of new business logic.
| name | symfony:strategy-pattern |
|---|---|
| description | Use when symfony strategy pattern |
symfony:strategy-pattern (Micro)
Use when
- Use when symfony strategy pattern
Rules
- Keep changes minimal and focused
- Ask before running servers/builds/tests
- Load reference/examples only on explicit request
References
reference.mddocs/complexity-tiers.md