acvos / bubbles
Bubbles DI 容器
1.0.1
2015-05-28 20:10 UTC
Requires
- php: >=5.5.9
Requires (Dev)
- pdepend/pdepend: 2.*
- phing/phing: 2.*
- phploc/phploc: 2.*@dev
- phpmd/phpmd: 2.*
- phpunit/phpunit: 4.5.*
- sebastian/phpcpd: 1.4.*
- squizlabs/php_codesniffer: 2.*
This package is not auto-updated.
Last update: 2024-09-28 17:12:37 UTC
README
极简、可扩展、懒加载的依赖注入容器。
为什么?
即使不使用全栈框架,遵循最佳实践也是有益的。如果你正在编写一个小型、专注的后端服务或脚本,但仍希望拥有 DI 的全部功能,Bubbles 将帮助将你的普通 PHP 类转换为可注入的服务。
如何?
安装
composer require acvos/bubbles
用法
// Instantiating Bubbles facade $bubbles = new Acvos\Bubbles\ContainerManager(); // Obtaining new DI container $container = $bubbles->spawn(); // Configuring dependencies $container ->register('zzz', 200) ->register('test.service', 'Acvos\Bubbles\Example\TestService') ->addDependency('Setter injection example', 'bob') ->addDependency('@zzz', 'bar') ->addDependency(100, 'foo') ->register('test.another.service', 'Acvos\Bubbles\Example\TestService') ->addDependency('@test.service') ->addDependency('zzz'); // Getting our class instance as a DI service $service = $container->get('test.another.service');