2017 © Pedro Peláez
 

library deinj

Dependency injection container

image

kambo/deinj

Dependency injection container

  • Monday, January 1, 2018
  • by kambo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Deinj - simple dependency injection container

Build Status Scrutinizer Code Quality Code Coverage Software License, (*1)

Just another simple dependency injection container with following highlights:, (*2)

  • Support of PSR-11 - Container interface

Install

Prefered way to install library is with composer:, (*3)

composer require kambo/deinj

Usage

use Kambo\Deinj\Container;

use Kambo\Examples\Deinj\Transport;
use Kambo\Examples\Deinj\Mailer;
use Kambo\Examples\Deinj\UserManager;

// Create instance of the container.
$container = new Container;

// Set object factory method for identifier 'transport'.
$container->set(
    'transport',
    // Factory method is plain callback.
    function () {
        return new Transport();
    }
);

// Set object factory method for identifier 'mailer'.
$container->set(
    'mailer',
    // Factory method is plain callback. An instance of the container must be passed inside
    // the closure for allowing of the 'transport' injection.
    function ($container) {
        return new Mailer($container->get('transport'));
    }
);

// Set object factory method for identifier 'userManager'.
$container->set(
    'userManager',
    // Factory method is plain callback. An instance of the container must be passed inside
    // the closure for allowing of the 'mailer' injection.
    function ($container) {
        return new UserManager($container->get('mailer'));
    }
);

// Get instance of the UserManager service.
$userManager = $container->get('userManager');

// Call register method in the UserManager service.
$userManager->register('username', 'password');

License

The MIT License (MIT), https://opensource.org/licenses/MIT, (*4)

The Versions

01/01 2018

dev-master

9999999-dev

Dependency injection container

  Sources   Download

MIT

The Requires

 

The Development Requires

27/12 2017

dev-develop

dev-develop

Dependency injection container

  Sources   Download

MIT

The Requires

 

The Development Requires

27/12 2017

v0.0.1

0.0.1.0

Dependency injection container

  Sources   Download

MIT

The Requires

 

The Development Requires