2017 © Pedro Peláez
 

library simpledi

Simple dependency injection container

image

kaihempel/simpledi

Simple dependency injection container

  • Tuesday, November 15, 2016
  • by kaihempel
  • Repository
  • 1 Watchers
  • 2 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

simpledi

Simple PHP dependency injection bundle, (*1)

Build Status Scrutinizer Code Quality Code Coverage, (*2)

This dependency injection container based on the idea to add the object construction code as closure. So every dependency can build with less convention restrictions., (*3)

Installing simpledi via Composer., (*4)

  "require": {
    "kaihempel/simpledi": "1.1.*"
  }

Create the dependency injection container instance:, (*5)

  $di = new \SimpleDI\SimpleDI();

Adding closures for instance creation:, (*6)

  $di->add('author', function($name) {
    return new Author($name);
  });

After adding the closure with the name "autor", the closure can be executed by calling the magic get method:, (*7)

  $author = $di->getAuthor($name);

To create instance with further dependencys, the dependency injection container can be commited to the closure by using the "use" keyword:, (*8)

  $di->add('book', function($name) use ($di) {
    return new Book($di->getAuthor($name));
  });

Like the description above, the "Book" instance will be initialized with a new author instance., (*9)

The container has a storage to save created objects. This feature have to be enabled by calling the "getStored()" method before calling the closure code:, (*10)

  $storedBook = $di->getStored()
                   ->getBook($name);

If no Book instance is stored, the closure execution saves the new instance in the storage., (*11)

The Versions

15/11 2016

dev-master

9999999-dev https://dev.kuweh.de/

Simple dependency injection container

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Kai Hempel

dependency injection

16/07 2016

1.1.0

1.1.0.0 https://dev.kuweh.de/

Simple dependency injection container

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Kai Hempel

dependency injection

04/04 2016

dev-analysis-XlKdmQ

dev-analysis-XlKdmQ https://dev.kuweh.de/

Simple dependency injection container

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by Kai Hempel

dependency injection

04/04 2016

1.0.0

1.0.0.0 https://dev.kuweh.de/

Simple dependency injection container

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by Kai Hempel

dependency injection

02/11 2015

0.1.1

0.1.1.0 https://dev.kuweh.de/

Simple dependency injection container

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by Kai Hempel

dependency injection

30/10 2015

0.1.0

0.1.0.0 https://dev.kuweh.de/

Simple dependency injection container

  Sources   Download

BSD-3-Clause

The Development Requires

by Kai Hempel

dependency injection