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!


Call to action

Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )

Thank you for reading! And see you soon on Strangebuzz! 😉

COil