conteneur dinjection de dépendance php

159

// short example of what DIC does
class Foo
{
    public function __construct(Bar $bar)
    {
    }
}

$foo = $container->get('Foo');
// Which is equivalent to the following
$bar = new Bar;
$foo = new Foo($bar);
class Foo
{
    public function __construct(Bar $bar)
    {
    }
}

$foo = $container->get('Foo');
// qui est équivalent à ce qui suit
$bar = new Bar;
$foo = new Foo($bar);

Comments

Submit
0 Comments