Using an environment variable (from `.env` file) in custom Twig function in Symfony 4
Here’s an easier way (Symfony 4) that does not involve any custom extensions. In my case, I wanted to set the Google Tag Manager Id as an environment variable in the .env file: GOOGLE_TAG_MANAGER_ID=”GTM-AAA12XX” Next, reference the environment variable in the config/packages/twig.yaml file: twig: globals: google_tag_manager_id: ‘%env(GOOGLE_TAG_MANAGER_ID)%’ Now you can use the tag manager value … Read more