0

i am trying to update phpdi from 5.4.6 to 6.4 and i don't know how to write a definition for objects which should be created everytime it is injected.

In 5.4.6 i simly wrote

return [
    'setasign\\Fpdi\\Fpdi' => DI\object()->scope(Scope::PROTOTYPE()),
]

But in 6.4 DI\object()->scope(Scope::PROTOTYPE()) does not exists anymore.

I read the documentation https://php-di.org/doc/scopes.html and understand that I can now use $container->make() instead of $container->get(), but then i have to rewrite much code in my repository.

Is there an option to resolve the problem in my definitionfile directly?

Thanks

With this way, i get the same instance every time i call $container->get()

setasign\\Fpdi\\Fpdi' => DI\factory(
    function () {
        return new setasign\Fpdi\Fpdi();
    }
)

0 Answers0