Can I use lazy services in typo3 (version 11)?
I have installed the package symfony/proxy-manager-bridge with composer require symfony/proxy-manager-bridge
. The documentation says that is enough.
When I debug the problem I find out that ContainerBuilder::proxyInstantiator
is null and ContainerBuilder::setProxyInstantiator()
is never called. I think it is the same problem as here.
Is there a way to call ContainerBuilder::setProxyInstantiator()
in typo3?
UPDATE
I was able to call ContainerBuilder::setProxyInstantiator()
in the typo3 context with a Service.php file. But it did not help with the lazy services.
// myext/Configuration/Services.php
// ...
return static function (ContainerConfigurator $container, ContainerBuilder $containerBuilder) {
$containerBuilder->setProxyInstantiator(new MyRuntimeInstantiator());
};
CodePudding user response:
TYPO3 does not support this integration for lazy services out of the box like Symfony does. Especially you cannot use Symfony bundles since these are integrations specifically meant for Symfony apps similar to extensions in TYPO3.
Within Symfony the Kernel::getContainerBuilder()
method is responsible for injecting the proxy instantiator. Here you can see how the Symfony-specific bundle is integrated in case it exists / is installed.
So you may need to try if you can achieve something similar with a Configuration/Services.php
which receives the ContainerBuilder
instance as argument. See the Services.php
of EXT:core for an example.
If it works well, you can even consider publishing this as TYPO3 extension package so that others can get this up and running with a simple package installation just like in Symfony.