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
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 )
- Report any error/typo.
- Report something that could be improved.
- Like and repost!
- Follow me on Bluesky 🦋
- Subscribe to the RSS feed.
- Click on the More on Stackoverflow buttons to make me win "Announcer" badges 🏅.
Thank you for reading! And see you soon on Strangebuzz! 😉