The dependency injection container for humans
open sourceMITfree
PHP-DI is a dependency injection container for PHP meant to be practical, powerful and framework-agnostic. It wires objects together by autowiring, PHP definition files and attributes, supports definition overriding, lazy injection and injecting into existing instances, and implements the PSR-11 container interface. Its documentation covers integrations with Symfony, Slim and other frameworks.
Problems it solves
- wire up dependencies in my PHP app without a big framework
- add a dependency injection container to a Slim app
- autowire constructor dependencies in PHP
Features
- autowiring of constructor dependencies
- PHP definition files and attribute-based injection
- definition extensions and overriding
- lazy injection and injection into existing instances
- implements the PSR-11 container interface
- documented integrations with Symfony, Slim and other frameworks
Limitations
- Needs PHP 8.0 or later.1
Alternatives
The same job
These do what PHP-DI does.
- laminas-servicemanager A factory-driven dependency injection container for PHP from the Laminas Project
- Pimple Small dependency injection container for PHP
