Laminas based helper for dependency injection
Setup:
\DannyMeyer\Di\Container::addConfiguration(
new \Laminas\ConfigAggregator\ConfigAggregator(
[
MyConfigProvider::class
]
)
);
Example for ConfigProvider:
class MyConfigProvider {
/**
* @return array
*/
public function __invoke(): array
{
return [
\DannyMeyer\Di\Container::CONFIG_DEPENDENCIES => [
\DannyMeyer\Di\Container::CONFIG_FACTORIES => [
MyClass::class => \Laminas\ServiceManager\Factory\InvokableFactory::class,
],
]
];
}
}
Usage:
$container = \DannyMeyer\Di\Container::getInstance();
$container->get(MyClass::class);