use Symfony\Component\DependencyInjection\Definition; $definition = new Definition(); $definition->setShared(true);
use Symfony\Component\DependencyInjection\Definition; $definition = new Definition(MyClass::class); $definition->setShared(false); $container->setDefinition('my_factory_service', $definition); // ... $myInstance = $container->get('my_factory_service')->create();In this example, a Definition object is created with the class MyClass and the isShared property is set to false. The Definition object is then added to the container as a service named 'my_factory_service'. When the 'my_factory_service' service is requested, a new instance of MyClass is created and returned. The package library for Symfony\Component\DependencyInjection is Symfony\Component\DependencyInjection itself. This is a PHP package that provides tools for managing dependencies in applications. It is part of the Symfony framework, which is a popular set of PHP web application components.