league/container
league/container is a lightweight PSR-11 dependency injection container for PHP. Define entries, factories, and autowiring-friendly services to manage application dependencies cleanly, with modern PHP support and solid tooling for testing and analysis.
#[Inject]).Adopt if:
#[Inject], #[Resolve]) without heavy frameworks like Symfony DI.Look elsewhere if:
For Executives: "This package lets us standardize how our PHP services are created and managed, reducing bugs from manual instantiation and making it easier to swap components (e.g., for testing or feature flags). It’s lightweight, widely used in the Laravel ecosystem, and supports modern PHP features like attributes. Adopting it aligns with our tech debt reduction goals and future-proofs our architecture for modular services."
For Engineering: *"league/container is a battle-tested, PSR-11-compliant DI container with:
#[Inject] to auto-wire dependencies (reduces boilerplate).ServiceProvider).@database.driver) for flexible retrieval.Why not Symfony DI? It’s heavier and overkill for most projects. This gives us 80% of the power with 20% of the complexity.
Migration Path:
new calls with container->get().ROI:
How can I help you explore Laravel packages today?