How to load Symfony's config parameters from database (Doctrine)
You are doing wrong things. You need to declare your CompilerPass and add it to the container. After whole container will be loaded... in the compile time you will have access to all services in it.
Just get the entity manager service and query for needed parameters and register them in container.
Step-by-step instruction:
Define Compiler pass:
# src/Acme/YourBundle/DependencyInjection/Compiler/ParametersCompilerPass.php class ParametersCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { $em = $container->get('doctrine.orm.default_entity_manager'); $paypal_params = $em->getRepository('featureBundle:paymentGateways')->findAll(); $container->setParameter('paypal_data', $paypal_params); } }
In the bundle definition class you need to add compiler pass to your container
# src/Acme/YourBundle/AcmeYourBundle.php class AcmeYourBundle extends Bundle { public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new ParametersCompilerPass(), PassConfig::TYPE_AFTER_REMOVING); } }