Automatic Dependency Resolution
composer require pengboomouch/audere
$myClass = $container->get('MyClass');
$myClass->doSomethingUseful();
use Audere\Inject;
class MyAttributeClass
{
private string $sayHello;
public function __construct(
#[Inject('say.hello')] $sayHello
) {
$this->sayHello = $sayHello;
}
public function getGreeting(): string
{
return $this->sayHello;
}
}
$builder = new InjectionBuilder();
$builder->add('say.hello', 'Hello World');
$container = new Audere\Container($builder);
$myAttributeClass = $container->get('MyAttributeClass');
echo $myAttributeClass->getGreeting(); //prints: Hello World