Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

If you don't want to statically create a parameter in parameters.yml or config.yml just for twig, you can create it dynamically in controller as shown below.


# sport/src/Football/FrontendBundle/Controller/DefaultController.php
namespace Football\FrontendBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
public function indexAction()
$this->get('twig')->addGlobal('my_global_twig_variable', 'inanzzz');

return $this->render('FootballFrontendBundle:Default:index.html.twig');


{{ my_global_twig_variable }}


If you call http://sport.local/app_dev.php in your browser, you should see output below.