title: How to load Symfony's config parameters from database (Doctrine)
body: <p>Instead of hard coding the parameters in <code>parameters.yml</code> I am trying to load them from database. Not all parameters in parameters.yml needs to be loaded from database just a few, like api details of paypal</p>
  
  <p>In <code>config.yml</code> I have imported the <code>parameters.php</code></p>
  
  <pre><code>imports:
      - { resource: parameters.php }
  </code></pre>
  
  <p>If I add static information in <code>parameters.php</code> like the one below it works fine</p>
  
  <pre><code>$demoName = 'First Last';
  $container-&gt;setParameter('demoName', $demoName);
  </code></pre>
  
  <p>However I am not able to fetch information from database table. I thought i should create class and make use of <code>$em = this-&gt;getDoctrine()-&gt;getManager();</code> and it should work but it doesn't and i get the error of </p>
  
  <p><code>Notice: Undefined variable: paypal_data in /opt/lampp/htdocs/services/app/config/parameters.php (which is being imported from "/opt/lampp/htdocs/services/app/config/config.yml").</code></p>
  
  <p>This is the attempt i made is as following but the code does not seem to go in <code>__construct()</code></p>
  
  <pre><code>use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Doctrine\Bundle\DoctrineBundle\Registry;
  use Doctrine\ORM\Mapping as ORM;
  
  class parameters extends Controller
  {
      public $paypal_data;
  
      function __construct() {
          $this-&gt;indexAction();
      }
  
      public function indexAction(){
  
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $this-&gt;paypal_data = $em-&gt;getRepository('featureBundle:paymentGateways')-&gt;findAll();
  
      }
  
  }
  $demoName = 'First Last';
  $container-&gt;setParameter('demoName', $demoName);
  $container-&gt;setParameter('paypal_data', $this-&gt;paypal_data);
  </code></pre>
  
  <p>Any help will be much appreciated.</p>