elephox / di
Elephox 依赖注入库。
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
- dev-develop
- 0.9.0.x-dev
- 0.8.0.x-dev
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.3
- 0.4.0
- 0.4.0-alpha5
- 0.4.0-alpha4
- 0.4.0-alpha3
- 0.4.0-alpha2
- 0.4.0-alpha1
- 0.3.27
- v0.3.25
- v0.3.24
- v0.3.23
- v0.3.22
- v0.3.21
- v0.3.20
- v0.3.18
- v0.3.17
- v0.3.16
- v0.3.15
- v0.3.14
- v0.3.13
- v0.3.12
- v0.3.11
- v0.3.10
- v0.3.9
- v0.3.8
- v0.3.7
- v0.3.6
- v0.3.5
- v0.3.4
- v0.1
- dev-release/0.9
- dev-release/0.8
- dev-release/0.7
- dev-release/0.6.0
- dev-16-psr-20-clock
- dev-18-make-servicecollection-more-extensible
- dev-release/0.6
- dev-release/0.5
- dev-release/0.4
- dev-release/0.3
This package is auto-updated.
Last update: 2024-08-30 01:39:37 UTC
README
此模块由 Elephox 使用以提供依赖注入容器。它还具有解决函数和回调参数的机制。
示例
<?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