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.


{% trans_default_domain 'snippet' %}

<h3>{{ 'current_env_145'|trans }} <code>{{ app.environment }}</code>!</h3>
HTML demo of the snippet

The current env is prod!


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

  Work with me!