2017 © Pedro Peláez
 

library new

Creating new instances auto injecting dependencies from a Pimple Container

image

gonzalo123/new

Creating new instances auto injecting dependencies from a Pimple Container

  • Sunday, November 16, 2014
  • by gonzalo123
  • Repository
  • 1 Watchers
  • 17 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Creating new instances auto injecting dependencies from a DIC, (*1)

Build Status, (*2)

class Foo
{
    public function hi($name)
    {
        return "Hi $name";
    }
}

class Another
{
    public function bye($name)
    {
        return "Bye $name";
    }
}

class Bar
{
    private $foo;

    public function __construct(Foo $foo, $surname = null)
    {
        $this->foo     = $foo;
        $this->surname = $surname;
    }

    public function hi(Another $another, $name)
    {
        return $this->foo->hi($name . " " . $this->surname) . ' ' . $another->bye($name);
    }
}

$container = new Pimple\Container   ();
$container['name'] = "Gonzalo2";

$builder = new G\Builder($container);

/** @var Bar $bar */
$bar = $builder->create('Bar', ['surname' => 'Ayuso']);
var_dump($builder->call([$bar, 'hi']));

var_dump($bar->hi(new Another(), 'xxxxx'));

The Versions

16/11 2014

dev-master

9999999-dev

Creating new instances auto injecting dependencies from a Pimple Container

  Sources   Download

MIT

The Requires

 

dependency injection container pimple