You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're not using the Delegate Lookup concept from the Container-Interop standard, ignore this bit. If you are,
you can do this:
$container = new \UltraLite\Container\Container();
$delegateContainer = new \UltraLite\CompositeContainer\CompositeContainer(); // or any delegate container$compositeContainer->addContainer($container); // will vary for other composite containers$container->setDelegateContainer($myCompositeContainer);
When the container is asked for a service using get(), it will return it. It will pass the Composite Container
into the factory closure, so it is from here that any dependencies of your service will be retrieved.
Alternatives
Ultra-Lite Container was originally inspired by Pimple, which still makes an
excellent DI container in PHP. Container-Interop compliant wrappers are available. Another excellent project,
Picotainer, is along similar lines, with the principle difference
being that the dependencies are defined at the time of instantiation of the container.
Installation
composer require ultra-lite/container
Contributions
Contributions welcome.
You can run the tests with ./vendor/bin/behat -c tests/behat/behat.yml and ./vendor/bin/phpspec r -c tests/phpspec/phpspec.yml.