Get the environment name in a Twig template with Symfony2 Get the environment name in a Twig template with Symfony2 symfony symfony

Get the environment name in a Twig template with Symfony2


Use

app.environment

e.g.

{% extends app.environment == 'dev' ? "::dev_layout.html.twig" : "::layout.html.twig" %}


Or you can use

app.debug

This returns true if debug is enabled. This is usually the case in the dev environment, however debug can be enabled in any of the environments... prod, test, dev, etc....