bnf / di
支持PSR-11和container-interop/service-provider的依赖注入容器
0.1.3
2019-02-09 11:41 UTC
Requires
- php: ^7.0
- container-interop/service-provider: ~0.4.0
- psr/container: ^1.0
Requires (Dev)
- php: ^7.1
- jangregor/phpstan-prophecy: ^0.3.0
- php-coveralls/php-coveralls: ^2.0
- phpspec/prophecy: ^1.7
- phpstan/phpstan: ^0.11.1
- phpstan/phpstan-phpunit: ^0.11.0
- phpstan/phpstan-strict-rules: ^0.11.0
- phpunit/phpunit: ^6.5 || ^7.0
- squizlabs/php_codesniffer: ^3.4
Provides
This package is auto-updated.
Last update: 2024-09-09 01:06:03 UTC
README
提供 PSR-11 和 container-interop/service-provider 支持。
安装
$ composer require bnf/di:~0.1.0
使用方法
<?php require 'vendor/autoload.php'; use Bnf\Di\Container; use Psr\Container\ContainerInterface; use Interop\Container\ServiceProviderInterface; $container = new Container([new class implements ServiceProviderInterface { public function getFactories(): array { return [ stdClass::class => function (ContainerInterface $container): stdClass { return new stdClass; } ]; } public function getExtensions(): array { return []; } }]); $class = $container->get(stdClass::class); var_dump($class);