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

Using %PROGRAMFILES(x86)% on Windows OS 32bit

According to this the environment variable %PROGRAMFILES(x86)% is only available on 64-bit systems. However, if you are on a 64-bit system and use %PROGRAMFILES%, the result you get depend on whether the process requesting the environment variable is 32-bit or 64-bit. So from a 64-bit process on a 64-bit system you would get C:\Program Files, … Read more

Is it safe to use os.environ.setdefault?

The os.environ documentation does state it’s a mapping: A mapping object representing the string environment. As such it behaves according to the python mapping documentation of which dict is the standard implementation. os.environ therefor behaves just like the standard dict, it has all the same methods: >>> import os >>> len(os.environ) 36 >>> ‘USER’ in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)