acvos / bubbles
Bubbles DI Container
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: 2025-03-29 20:03:40 UTC
README
Minimalistic, extensible, lazy dependency injection container.
Why?
It's always good to follow best practices even when you don't use a full-stack framework. If you are writing a small, focused back-end service or script, but still want the full power of DI, Bubbles would help turning your plain old PHP classes into injectable services.
How?
Installation
composer require acvos/bubbles
Usage
// 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');