title: How to define global variables for Twig templates with values coming from the DB?
body: <p>I would like to define a global variable for twig, which would be accessible from any template.</p>
  
  <p>I can create a global variable in symfony's <code>config/packages/twig.yaml</code>, but I need it to be a value obtained from the database.</p>
  
  <p>In the documentation for twig it says to use this code:  </p>
  
  <pre class="lang-php prettyprint-override"><code>$twig = new Twig_Environment($loader);
  $twig-&gt;addGlobal('name', 'value');
  </code></pre>
  
  <p>Where should I use this code so this varible is available for every template?</p>