2017 © Pedro Peláez
 

library con-boss

A light context manager for DI and IoC

image

naylonkessler/con-boss

A light context manager for DI and IoC

  • Saturday, August 12, 2017
  • by naylonkessler
  • Repository
  • 2 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

ConBoss

SensioLabsInsight Build Status, (*1)

ConBoss is a light context manager (container) for using with dependency injection and inversion of control concepts. It is intended to be simple and light but still powerful., (*2)

Installation

Just require the package using composer., (*3)

composer require naylonkessler/con-boss

Using the package

Import and create a container:, (*4)

<?php

use ConBoss\Container;

$container = new Container();

After bind some dependencies:, (*5)

// Bind a name to a class FQN
$container->bind('name', Some\Class::class);

// Bind an interface FQN to a class FQN
$container->bind(Some\Interface::class, Some\Class::class);

// Bind an interface FQN to a factory closure
$container->bind(Some\Interface::class, function ($container) {
    return new \Some\Class();
});

// Bind a variable
$container->bind('$varName', 'Any content');

// Bind an interface FQN to a shared class FQN
$container->share(Shared\Interface::class, Some\Shared\Class::class);

And finally request some bind from container:, (*6)

// Get some bind name from container
$some = $container->get('name');

// Get some variable from container
$var = $container->get('$varName');

// Get multiple values from container
list($name, $var) = $container->get(['name', '$varName']);

You can also unbind something from container and check if some binding exists:, (*7)

// Unbind a name from container
$container->unbind('name');

// Check if some bind exists
$exists = $container->has('name');

Except for Container::get() and Container::has() methods that returns especific values you can take advantage of chained calls if you prefer:, (*8)

// Chained calls
$container->share('some-shared', Some\Shared::class)
    ->bind('some-bind', Some\Bind::class)
    ->bind('$someVar', 10);

The Versions

12/08 2017

dev-master

9999999-dev

A light context manager for DI and IoC

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Naylon Kessler de Aquino

17/02 2017

v0.0.0

0.0.0.0

A light context manager for DI and IoC

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Naylon Kessler de Aquino