zendframework/zend-di
zendframework/zend-di is a PHP dependency injection container for Zend Framework apps. It supports autowiring, configurable definitions, and factories to build and wire objects at runtime, helping manage dependencies and improve testability.
php-di/php-di or Symfony's Dependency Injection Container.composer require zendframework/zend-di.$di = new Zend\Di\Di();
$service = $di->get('Some\Dependency\Class');
Di class constructor — it supports configuration via array, allowing definitions, shared instances, and prefilters.Di scans type hints and resolves dependencies automatically:
class Service {
public function __construct(RepositoryInterface $repo) { /* ... */ }
}
// $di->get(Service::class);
Zend\Di\Definition\RuntimeDefinition for runtime-based conditional wiring.DefinitionSource:
$defs = new Zend\Di\Definition\DefinitionDecorator($config['di']);
$di = new Zend\Di\Di($defs);
Zend\Di\DiServiceManager to bridge Di with Zend\ServiceManager, enabling DI-driven service resolution in controllers and modules.Di resolves dependencies at runtime — avoid production use without caching (DefinitionList + CompiledDefinitions).Di does not detect or handle circular references gracefully — throws Exception\InfiniteRecursionException; design dependencies carefully.get() calls without caching cause repeated reflection scanning — cache definitions using DefinitionCompiler for production.ContainerInterface; cannot be used interchangeably with modern containers.Zend\Di for php-di/php-di with minimal config changes.How can I help you explore Laravel packages today?