use Symfony\Component\DependencyInjection\Definition; $definition = new Definition('MyService'); $definition->setLazy(true);
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; $container = new ContainerBuilder(); $definition = new Definition('MyService'); $definition->setLazy(true); $container->setDefinition('my_service', $definition);In this example, a new container builder is created, and then a service definition is created and set to lazy loading. Finally, the definition is added to the container with the name "my_service". This feature is part of the Symfony DependencyInjection component.