lebran/container

The simple di for lebran projects.

dev-master 2016-02-16 14:43 UTC

This package is not auto-updated.

Last update: 2024-11-05 05:00:53 UTC


README

Simple dependency injection container

Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version License

Installation

Require in your project with composer :

$ composer require lebran/container

Example

In your bootstrap file index.php :

<?php

// Include autoloader
include __DIR__."/vendor/autoload.php";

// Create service container
$di = new \Lebran\Container();

// Container supports 3 types of definition

// Type 1: Object
$di->set('myservice', new \MyNamespace\MyService());

// Type 2: String
$di->set('myservice2', '\MyNamespace\MyService2');

// Type 3: Closure
$di->set('myservice3', 
    function(){
        return new \MyNamespace\MyService3();
    }
);

// Getting service 
$di->get('myservice');

Extended example coming soon ...