next/di
最新稳定版本:0.2.0
Composer 安装命令:
composer require next/di
包简介
A lightweight dependency injection tool, container based on the PSR-11 specification.
README 文档
README
一款简单的容器,所有被容器实例化的类以及所有依赖都是单例
安装
环境要求 PHP >= 8.0
composer require next/di
使用
获取容器实例,注意不要直接实例化
$container = \Next\Di\Context::getContainer(); $container = container();
绑定类和别名,之后所有容器接口都可以使用TestInterface::class标识来获取Test::class实例
$container->bind(TestInterface::class, Test::class);
实例化
$container->make(Test::class);
获取对象
$container->get(Test::class);
调用方法
$conatiner->call(callable $callable, array $arguments = []);
注意:所有需要传参的api均需要关联数组,数组的键为参数的名字
统计信息
- 总下载量: 64
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-10-31