zorachka / container
Zorachka 容器
v3.1.0
2023-04-04 15:29 UTC
Requires
- php: ^8.1
- ext-apcu: *
- php-di/php-di: ^7.0
- webmozart/assert: ^1.11
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.9
- phpstan/phpstan-phpunit: ^1.2
- phpunit/phpunit: ^9.5
README
Zorachka 容器
此包提供了一个用于兼容 PSR-11 的 依赖注入 容器的工厂,该工厂能够实例化和配置类,解析依赖项和 ServiceProvider
接口。
使用 PHP-DI 作为核心。
安装
您可以通过 composer 安装此包
composer require zorachka/container
用法
要创建容器,需要传递一个包含 ServiceProvider
对象接口的数组
<?php declare(strict_types=1); use Psr\Container\ContainerInterface; use Zorachka\Container\ContainerFactory; use Zorachka\Container\ServiceProvider; $container = ContainerFactory::build([ new class implements ServiceProvider { /** * @inheritDoc */ public static function getDefinitions(): array { return [ stdClass::class => static fn() => new stdClass(), ]; } /** * @inheritDoc */ public static function getExtensions(): array { return [ stdClass::class => static function ($stdClass, ContainerInterface $container): stdClass { $stdClass->property = 'value'; return $stdClass; } ]; } } ]);
测试
make test
变更日志
请参阅 CHANGELOG 以获取有关最近更改的更多信息。
贡献
请参阅 CONTRIBUTING 以获取详细信息。
安全漏洞
请审查 我们的安全策略 了解如何报告安全漏洞。
致谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 以获取更多信息。