a50 / container-php-di
A50容器
dev-main
2024-04-22 07:46 UTC
Requires
- php: ^8.1
- ext-apcu: *
- a50/container: dev-main
- php-di/php-di: ^7.0
- webmozart/assert: ^1.11
This package is auto-updated.
Last update: 2024-09-22 08:37:45 UTC
README
A50容器
此包提供了一个用于兼容PSR-11的依赖注入容器工厂,该容器能够实例化和配置类,解决依赖并实现ServiceProvider
接口。
使用PHP-DI作为核心。
安装
您可以通过composer安装此包
composer require a50/container
用法
要创建容器,您需要传递一个包含ServiceProvider
对象接口的数组
<?php declare(strict_types=1); use Psr\Container\ContainerInterface; use A50\Container\ContainerFactory; use A50\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)。请参阅许可证文件以获取更多信息。