2017 © Pedro Peláez
 

library di

A dependency injection container.

image

jaeger-app/di

A dependency injection container.

  • Tuesday, July 5, 2016
  • by mithra62
  • Repository
  • 1 Watchers
  • 0 Stars
  • 88 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Jaeger Dependency Injection Container

Build Status Scrutinizer Code Quality Author GitHub license, (*1)

A simple dependency injection container for use with Jaeger (or stand alone)., (*2)

Installation

Add jaeger-app/di as a requirement to your composer.json:, (*3)

$ composer require jaeger-app/di

Adding Services

Ideally, like all Jaeger classes, you should extend Jaeger\Bootstrap and initialize the parent services before adding your own like the below:, (*4)

use \JaegerApp\Di;

class MyDi extends Di
{
    public function getServices()
    {
        $this->container = parent::getServices(); //init existing services

        //add new service
        $this->container['my_service'] = function ($c) {
            $settings = new NewService;
            return $settings;
        };

        return $this->container;
    }
}

You can also add new Services at run time by using the setService($name, \Closure $function) method., (*5)

use \JaegerApp\Di;

$di = new Di();
$callable = function() {
    return 'foo to the who';
};

$di->setService('test_service', $callable);

Calling Services Example

use \JaegerApp\Di;

$di = new Di();

//get all the services
$services = $di->getServices();

//get a specific service
$db = $services['db']; 

//or get specific service directly
$db = $di->getService('db');

The Versions

05/07 2016

dev-master

9999999-dev

A dependency injection container.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Lamb

dependency-injection di

05/07 2016

0.1.1

0.1.1.0

A dependency injection container.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Lamb

dependency-injection di

19/04 2016

0.1

0.1.0.0

A dependency injection container.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Lamb

dependency-injection di