Symfony Dependency Management
INFO
This document represents an architecture decision record (ADR) and has been mirrored from the ADR section in our Shopware 6 repository. You can find the original version here
Context
Recent versions of Symfony have introduced various new features for dependency management that simplify service configuration and improve the developer experience.
These features are now available in Shopware and include:
Decision
Shopware now supports the following modern Symfony dependency management features:
- Autowiring: Services can be automatically resolved by Symfony using type hints, reducing the need for explicit service definitions.
- PHP-based service configuration: Service configuration can be loaded from PHP files in addition to XML and YAML.
- Autowire attribute: Services requiring non-default implementations or scalar values can use the
Autowire
attribute for configuration.
Note: Attributes should only be used in framework glue code, such as Controllers and Commands. Domain code should remain decoupled from Symfony-specific implementations.
With autowiring enabled, dependency graphs can be automatically resolved by Symfony using type hints, significantly reducing configuration overhead.
Benefits for plugin development
Plugin developers can now leverage these features to:
- Reduce boilerplate configuration code
- Benefit from better IDE autocompletion with PHP-based configuration
- Use a more modern, streamlined approach