Why use containers for DI when you can have a top-down approach with lazy objects (8.4+)?
I am not PHP proficient. Is there any reason to avoid manually wiring the dependency graph? Do developers use this feature? It's been almost 2 years since 8.4 released with the lazy objects feature and it's one dependency less.
Short example:
class LazyAppFactory
{
public PgTransactor $pgTransactor;
public AuthenticationRepo $authenticationRepo;
public AuthService $authService;
public AuthController $authController;
public function __construct()
{
// postgres module
$this->authenticationRepo = new \ReflectionClass(AuthenticationRepo::class)->newLazyGhost(function ($ghost) {
$ghost->__construct($this->pgTransactor);
});
// service, controller modules
}
}
And then simply use the controllers in the handler / entry point of the app.