Compared to Aura/Di version 4, all LazyInterface instances were directly invokable. This has changed in version 5. Now, LazyInterface requires to be passed a Resolver.
This has two advantages:
You can instantiate a LazyInterface without needing the Resolver or the Container. This was required to implement the attributes #[Service], #[Instance] and #[Value].
It reduces circular references when serializing.
But, sometimes, you do need a directly invokable object, e.g. when creating a route handler. Such an object needs to be invokable without passing the Resolver as a parameter. This is what the new LazyLazy solves. It wraps a LazyInterface with the Resolver, making the object directly invokable.
Compared to
Aura/Di
version 4, allLazyInterface
instances were directly invokable. This has changed in version 5. Now,LazyInterface
requires to be passed aResolver
.This has two advantages:
LazyInterface
without needing theResolver
or theContainer
. This was required to implement the attributes#[Service]
,#[Instance]
and#[Value]
.But, sometimes, you do need a directly invokable object, e.g. when creating a route handler. Such an object needs to be invokable without passing the
Resolver
as a parameter. This is what the newLazyLazy
solves. It wraps aLazyInterface
with theResolver
, making the object directly invokable.