phpolar/property-injector
最新稳定版本:1.1.2
Composer 安装命令:
composer require phpolar/property-injector
包简介
Provides automatic dependency injection for properties.
README 文档
README
Property Injector
Provides automatic dependency injection for properties.
Quick Start
class Example1 { /** * Will set this property with the * value in the DI container * that is registered with 'DEPENDENCY_ID' */ #[Inject("DEPENDENCY_ID")] public string $property; } class Example2 { /** * Will set this property with the * value in the DI container * that is registered with the claass name * in the type hint */ #[Inject] public SomeDependency $property; } class Example3 { /** * Will ignore protected properties. */ #[Inject] protected SomeDependency $property; /** * Will ignore private properties. */ #[Inject] private SomeDependency $property; } $injectee = new Example1(); (new PropertyInjector($psr11Container))->inject($injectee); $injectee->property === $psr11Container->get("DEPENDENCY_ID"); // true
API Documentation
Thresholds
| Source Code Size * | Memory Usage |
|---|---|
| 2300 B | 5.5 kB |
- Note: Does not include comments.
统计信息
- 总下载量: 462
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-21