Environment variables in Twig
Time to time you may need to have access to information, in Twig, that you can not save in your code nor in the CMS/backend.
For example a phone number that you don't want to see indexed by Google from Your GitHub repository.
On this website, I need my mobile number for my resume. But I do not want to have it, as a transklation key, commit on GitHub.
Another example are urls which typically depend on the deployment environment. So when you deploy en ACC the urls are not the same. And you do not want to update your DB each time that your update your ACC from your PROD enviroment.
With this Twig snippet you are abel to get a DATA_PHONE environment variable:
{{ app.request.server.all['DATA_PHONE']|default('+32 4XX XX.XX.XX') }}
Last posts
- Draw.io on a website
- Deploy elasticms on AWS
- Intégrer BOSA Accessibility Check dans un site web [Content in French]
- PHP - Convert Human Readable Size to Bytes
- Composer: How to use a specific branch acting like a specific revision in composer dependencies
- Stream a CSV from a JSON array
- Comment utiliser les commandes "locales" du skeleton [Content in French]
- How to extract data from a JsonMenuNestedEditorField
- Backup on AWS glacier
- Refer to environment variables in twig