<?php
/**
* the simple DI only works without
* config when there are dependencies
* to classes via type hint
*/
class Foo
{
public $prop = 'foo';
}
class Bar
{
private $foo;
/**
* DI container recognizes Foo class dependency
* and creates Foo object automatically
*/
public function __construct(Foo $foo)
{
$this->foo = $foo;
}
public function getFooProp()
{
return $this->foo->prop;
}
}
use Laminas\Di\Di;
$di = new Di();
$bar = $di->get('Bar');
echo $bar->getFooProp();