Q:

Configuring a Silex-Application with paths using Symfony\Component\DependencyInjection

I am currently refactoring a Silex\Application that has grown bigger than initially expected. As part of this work I am moving service definitions from the source into a services.yml and just call a Symfony\Component\DependencyInjection\ContainerBuilder instead. The code looks like this:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
$loader->load(__DIR__ . '/services.yml');

Consider the following line of code, which is part of creating a Doctrine\ORM\EntityManager:
Setup::createAnnotationMetadataConfiguration(array("src/Project/Entity"), true);

which looks like this in my services.yml:
services:
    doctrine_config:
        class: Doctrine\ORM\Configuration
        factory_class: Doctrine\ORM\Tools\Setup
        factory_method: createAnnotationMetadataConfiguration
        arguments:
            - [src/Project/Entity]
            - true

Finally, my question. I want to pass a key and value to the container builder, which I can access like a parameter, e.g. instead of [src/Project/Entity] as first argument for the Doctrine-Setup I want to do something like this: [%ROOT_PATH%/src/Project/Entity], where %ROOT_PATH% is added to the ContainerBuilder somewhat like this $container->???('ROOT_PATH', dirname(__DIR__)).
I found nothing like this in the documentation. I will read through the ContainerBuilder.php to see if I can find something, but I am not sure about the terminology, e.g. whether %OOT_PATH% in my scenario is a variable, definition, alias...

A:

Found it myself.
It's as simple as adding:
$container->setParameter("ROOT_PATH", dirname(__DIR__));

in my snippet above.

