use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $container->register('my_service', 'My\Class\Here'); $container->setAlias('my_alias', 'my_service'); // Get the alias for the service ID 'my_service' $alias = $container->getAlias('my_service'); // Returns 'my_alias' echo $alias;
use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $container->setParameter('my_param', 'my_value'); $container->setAlias('my_alias', 'my_param'); // Get the alias for the parameter 'my_param' $alias = $container->getAlias('my_param'); // Returns 'my_alias' echo $alias;In this example, we first define a parameter 'my_param' with the value 'my_value'. We then set an alias 'my_alias' for this parameter using the setAlias method. Finally, we use the getAlias method to retrieve the configured alias for the parameter 'my_param'. The output of this example will be 'my_alias'. Package library: Symfony/DependencyInjection