elephox / di
Elephox dependency injection library.
v0.7.0
2022-10-17 22:35 UTC
Requires
- php: ^8.1 <8.3
- elephox/collection: dev-develop
- jetbrains/phpstorm-attributes: ^1.0
- psr/container: ^2.0
Provides
This package is auto-updated.
Last update: 2026-05-29 01:51:58 UTC
README
This module is used by Elephox to provide a dependency injection container. It also has mechanisms to resolve arguments for functions and callbacks.
Example
<?php use Elephox\DI\ServiceCollectionOld; $container = new ServiceCollectionOld(); $container->addSingleton(stdClass::class, stdClass::class, fn () => new stdClass()); $foo = function (stdClass $object) { return $object; } $instance = $container->resolver()->call($foo); // $instance is an instance of stdClass // multiple calls to $container->resolver()->callback($foo) will return the same instance, since it was added as a singleton