av / bonefish-di2
This package is abandoned and no longer maintained.
The author suggests using the av/bonefish-injection package instead.
There is no license information available for the latest version (v2.0) of this package.
This Project maintains the Bonefish Dependency Injection Container
v2.0
2014-10-04 18:44 UTC
Requires
- php: >=5.3.0
- nette/reflection: dev-master
This package is not auto-updated.
Last update: 2019-02-20 18:11:16 UTC
README
Bonefish-DI2 is a dead simple and small Dependency Injection Container. This is basically the same as Bonefish-DI but uses Nette\Reflection for easier annoation support
Features
- Inject services with @inject annotation
- Lazy dependency injection by default
Installation
Please use Composer to install this package.
$ composer require av/bonefish-di2:dev-master
Usage
Simple creating with injection without adding it into the container
// Create an Object and inject all Services $container = new Bonefish\DependencyInjection\Container(); $foo = $container->create('\Some\Random\Class'); // or with parameters $bar = $container->create('\Some\Random\Class',array('bar','baz'));
Create a new service and save it in the container
// Create a service, no parameters here $container = new Bonefish\DependencyInjection\Container(); $service = $container->get('\Some\Random\Service');
You can also create Objects and add them later to be used as services
// Create an Object and inject all Services $container = new Bonefish\DependencyInjection\Container(); $bar = $container->create('\Some\Random\Class',array('bar','baz')); $container->add('\Some\Random\Class',$bar);
You can also define aliases
// Create an Object and inject all Services $container = new Bonefish\DependencyInjection\Container(); $service = $container->get('\Some\Random\Service'); $container->alias('Alias','\Some\Random\Service'); // This will now return \Some\Random\Service $service2 = $container->get('Alias');
You can also check if an alias is set, tear down the whole container and list all services in this container.