Contents
- 1. What are Virtual Types?
- 2. Syntax and basic structure
- 3. Classic example: multiple loggers
- 4. Magento core: Virtual Types everywhere
- 5. Strategy selection via Virtual Type
- 6. Decorator chain without PHP code
- 7. Virtual Type as factory configuration
- 8. Debugging Virtual Types
- 9. Limits of Virtual Types
- 10. Conclusion: when to use Virtual Types?
Virtual Types are one of the most powerful and most frequently misunderstood features of Magento's DI system. They let you use a single class multiple times with different configurations, without writing a single line of PHP code. Instead of creating a new class, you create a virtual name for