conteneur d'injection de dépendance php

PHP
// 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);

Source

Also in PHP: