progphil1337/php-di
最新稳定版本:v1.0.0
Composer 安装命令:
composer require progphil1337/php-di
包简介
Simple but effective dependency injection library
README 文档
README
Simple but effective dependency injection library
Installation
Install with composer:
$ composer require progphil1337/php-di
Compatibility
ProgPhil1337\DependencyInjection requires PHP 8.1 (or better).
Usage
Basic example
ExampleForm.php
use ProgPhil1337\DependencyInjection\ClassLookup; use ProgPhil1337\DependencyInjection\Injector; use MyApp\YamlConfig; use MyApp\AbstractConfig; use MyApp\SingletonInterface; $lookup = new ClassLookup(); $injector = new Injector($lookup); $lookup // class aliases ->alias(YamlConfig::class, AbstractConfig::class) // register singletons ->singleton(SingletonInterface::class) // Register classes that cannot be created ->register(new YamlConfig()) ; // Example for alias and registering $yamlConfig = $injector->create(AbstractConfig::class);
统计信息
- 总下载量: 195
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-15