digitalwindow/dependency-injection

Easy-to-use Dependency Injection in PHP

1.0.7 2014-03-21 15:09 UTC

This package is not auto-updated.

Last update: 2024-04-09 04:08:25 UTC


README

Dependency injection for PHP

Usage Examples

$injector = new \Awin\DependencyInjection\DependencyInjector;
$injector->configureDependencyParamValue('Foo', 'param1', 'value to use in constructor');
$injector->configureDependencyParamClass('Foo', 'param2', '\Bar');
$foo = $injector->get('Foo')';

Configuration-Free Usage

Simply type-hint the constructor parameters of your dependency, and you needn't offer any configuration information to the injector - it will use reflection to figure out what is needed.

E.g.:

class Foo
{
    public function __construct(Bar $param)
    {
        //...
    }
    //...
}
$foo = $injector->get('Foo'); // Constructor param retrieved recursively from
                              // injector at this point, based on type-hint.

Build Status