2017 © Pedro Peláez
 

library autoinstantiator

Demo of automatic object resolution using PHP's reflection API.

image

jtaurus/autoinstantiator

Demo of automatic object resolution using PHP's reflection API.

  • Saturday, August 22, 2015
  • by jtauri
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

autoinstantiator

Demo of automatic object resolution using PHP's reflection API., (*1)

How does it work

Pass a classname to Autoinstantiators build method and receive an object with all of its dependencies instantiated for you:, (*2)

$barInstance = (new AutoInstantiator())->build("jtaurus\autoinstantiator\Bar"), (*3)

Bars constructor:, (*4)

public function __construct(Foo $fooInstance, Baz $bazInstance, $someString = "somethingValue"), (*5)

AutoInstantiator will look at specified class constructor. If it has any dependencies that we are able to resolve, it will add them to dependency array and use ReflectionClass::newInstanceMethod($args) to assemble them into a new instance of a given class., (*6)

Works for typehinted parameters and parameters with default values., (*7)

Does not work for parameters that don't have at least one of these things. There is no way of knowing what value should we assign to it., (*8)

The Versions

22/08 2015

dev-master

9999999-dev

Demo of automatic object resolution using PHP's reflection API.

  Sources   Download

The Development Requires

by Jakub