DI is a simple dependency injection manager.

1.0.1 2016-05-30 06:56 UTC

This package is not auto-updated.

Last update: 2024-11-09 20:33:37 UTC


README

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

This is a simple dependency injection manager.

Installation

To install through composer, simply put the following in your composer.json file:

{
    "require": {
        "ozziest/di": "dev-master"
    }
}
$ composer update

Usage

class CustomModel {
    
    public function __construct(IDB $db)
    {
        
    }
    
}

class MyController {
    
    public function __construct(IModel $model, IRepository $repository, CustomModel $model)
    {
        
    }
    
}

Ozziest\DI::bind('IModel', 'MyModel');
Ozziest\DI::bind('IRepository', 'MyRepository');
Ozziest\DI::bind('IDB', 'MyDB');

$instance = Ozziest\DI::resolve('MyController');

// equals this
$instance = new MyController(
    new MyModel(), 
    new MyRepository(), 
    new CustomModel(new MyDB())
);