PHP-DI allows some methods to define injections, including factories and objects: http://php-di.org/doc/php-definitions.html.
Factories:
TestClass::class => function () {
return new TestClass('param');
}
The TestClass
instance is created lazily, only when it is needed.
Objects:
TestClass::class => DI\object()->constructor('param')
If you use Objects, is the instance also created lazily?
If yes, what's the difference between factories and objects?