Getting the current environment in a Twig template with Symfony

Published on 2021-05-05 • Modified on 2021-05-05

In this snippet, we see how to get the current environment in a Twig template with Symfony. This is simple to do thanks to the twig app global variable.


HTML demo of the snippet

The current env is prod!


{% trans_default_domain 'snippet' %}

<h3>{{ 'current_env_145'|trans }} <code>{{ app.environment }}</code>!</h3>

 More on Stackoverflow   Read the doc  More on the web  Random snippet