2017 © Pedro Peláez
 

library di-hub

Dependency injection library for PHP with links consistency maintaining mechanism

image

nayjest/di-hub

Dependency injection library for PHP with links consistency maintaining mechanism

  • Monday, May 22, 2017
  • by nayjest
  • Repository
  • 1 Watchers
  • 1 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 6 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

DI-Hub (Dependency Injection Hub)

IoC container for PHP with hierarchy and links consistency maintaining mechanism, (*1)

Build Status, (*2)

SensioLabsInsight, (*3)

Table of Contents

Requirements

  • PHP 5.5+ (HHVM & PHP7 are supported)

Installation

The recommended way of installing this package is through Composer., (*4)

Run following command from your project folder:, (*5)

composer require nayjest/di-hub

Usage

Creating hub

Class Nayjest\DI\Hub represents IoC container. This class implements ContainerInterface from container-interop/container-interop package., (*6)

Hub can be instantiated without arguments or with array containing definitions., (*7)

use Nayjest\DI\Hub;
# Empty hub
$hub = new Hub;

# Hub with definitions

$hub = new Hub([
  new Value('item1', $item1),
  new Value('item2', $item2),
  new Relation('item1', 'item2', $handler),
]);

Definitions

There are several types of definitions that can be added to hub: - Values - Relations - Items, (*8)

Definitions should implement Nayjest\DI\Definition\DefinitionInterface. This intarface don't contains any methods, it's used only to signalize that instances of target class defines data or relations inside container., (*9)

Definitions can be added to container(hub) in following ways: 1) Inject array of definition instances into hub constructor 2) Add definition instance to existing hub via $hub->addDefinition(DefinitionInterface $definition) 3) Add array of definition instances to existing hub via $hub->addDefinitions(DefinitionInterface[] $definitions) 4) Create definitions via DefinitionBuilder: $hub->builder()->define($id $source), (*10)

Value Definitions

Instance of Nayjest\DI\Definition\Value represent single value in container that can be accessed by it's id. Nayjest\DI\Definition\Value accepts two arguments: id and source. source can contain value to store inside hub or callable that returns target value., (*11)

# Add data directly to definition
$hub->addDefinition(new Value('item1', $data));

# Add data via callable
$hub->addDefinition(new Value('item2', function(){
   return $data;
}));

Relation Definitions

@todo, (*12)

Item Definitions

Item is a combination of value & it's initial dependencies. May be useful to store class instances that require DI in constructor., (*13)

@todo, (*14)

Hierarchy of hubs

@todo, (*15)

Testing

This package bundled with unit tests (PHPUnit)., (*16)

1) Install nayjest/di-hub as stand-alone project, (*17)

composer create-project nayjest/di-hub -s dev

2) Run tests from package folder, (*18)

cd di-hub
composer test

Also it's possible to check code style (PSR-2):, (*19)

composer code-style

Contributing

Please see Contributing Guidelines and Code of Conduct for details., (*20)

Security

If you discover any security related issues, please email mail@vitaliy.in instead of using the issue tracker., (*21)

License

© 2016—2017 Vitalii Stepanenko, (*22)

Licensed under the MIT License., (*23)

Please see License File for more information., (*24)

The Versions

22/05 2017

dev-master

9999999-dev

Dependency injection library for PHP with links consistency maintaining mechanism

  Sources   Download

MIT

The Requires

 

The Development Requires

by Vitalii [Nayjest] Stepanenko

dependency injection service locator ioc inversion of control di container di service provider ioc container

22/05 2017

dev-v0.6-dev

dev-v0.6-dev

Dependency injection library for PHP with links consistency maintaining mechanism

  Sources   Download

MIT

The Requires

 

The Development Requires

by Vitalii [Nayjest] Stepanenko

dependency injection service locator ioc inversion of control di container di service provider ioc container

30/03 2017

dev-v0.3-dev

dev-v0.3-dev

Dependency injection library for PHP with links consistency maintaining mechanism

  Sources   Download

MIT

The Requires

 

The Development Requires

by Vitalii [Nayjest] Stepanenko

dependency injection service locator ioc inversion of control di container di service provider ioc container

28/03 2017

dev-v0.4-dev

dev-v0.4-dev

Dependency injection library for PHP with links consistency maintaining mechanism

  Sources   Download

MIT

The Requires

 

The Development Requires

by Vitalii [Nayjest] Stepanenko

dependency injection service locator ioc inversion of control di container di service provider ioc container

02/03 2017

dev-v0.2-dev

dev-v0.2-dev

Dependency injection library for PHP with links consistency maintaining mechanism

  Sources   Download

MIT

The Requires

 

The Development Requires

by Vitalii [Nayjest] Stepanenko

dependency injection service locator ioc inversion of control di container di service provider ioc container

07/02 2017

v0.1.0

0.1.0.0

Dependency injection library for PHP with links consistency maintaining mechanism

  Sources   Download

MIT

The Requires

 

The Development Requires

by Vitalii [Nayjest] Stepanenko

dependency injection service locator ioc inversion of control di container di service provider ioc container