erip/ldic

PHP 的轻量级依赖注入容器。

1.0 2020-06-24 20:40 UTC

This package is auto-updated.

Last update: 2024-09-25 06:54:02 UTC


README

Latest Version Software License Total Downloads

LDic 是一个用于 PHP 的轻量级依赖注入容器。只需 3 个公共函数和不到 130 行代码。

安装

通过 Composer

$ composer require erip/ldic

用法

class Foo {}

$container = new Erip\LDic();
$container->register(new Foo());
$productUtils = $container->resolve(Foo::class);

// Lazy Registration

// This dependency will be created only when needed.
$container->lazyRegister(function(){
    return new Foo();
});

$productUtils = $container->resolve(Foo::class);

测试

$ phpunit

贡献

请参阅CONTRIBUTING 获取详细信息。

致谢

许可证

MIT 许可证(MIT)。有关更多信息,请参阅许可证文件