use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; $container = new ContainerBuilder(); $definition = new Definition('MyServiceClass'); $definition->addArgument('Some argument for MyServiceClass'); $container->setDefinition('my_service', $definition);
use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $myService = $container->get('my_service');In this example, we create a new ContainerBuilder, and retrieve an instance of our registered service using the get() method. Overall, ContainerBuilder is a powerful tool that allows you to manage service dependencies and parameter values in your Symfony application.