Cms: env tag not working

Created on 8 Feb 2020  路  2Comments  路  Source: statamic/cms

I've been using the env tag to pull in things like Stripe keys, but this appears to have stopped working in the latest update. The format I'm using is {{ env:VALUE }}. Adding a default does generate the default value.

not a bug

Most helpful comment

If you use the config:cache command, env will not work. (Only in config files)

Actually I would like to remove the env template tag.

It's best/better practice to place your env() calls within your config file, then reference the config where necessary.

You can reference the config from within your templates.
For example, the route variable in the config/statamic/cp.php file:

{{ config:statamic:cp:route }}

All 2 comments

Follow-up: env variables were also not available in my separate app I'm using for stripe transactions, unless I repeatedly ran "php artisan config:cache". Ended up doing a hard reset from my remote repository to fix (with git clean -ffdx and a composer update). So, not sure if this is related to Statamic or just something else that got corrupted.

If you use the config:cache command, env will not work. (Only in config files)

Actually I would like to remove the env template tag.

It's best/better practice to place your env() calls within your config file, then reference the config where necessary.

You can reference the config from within your templates.
For example, the route variable in the config/statamic/cp.php file:

{{ config:statamic:cp:route }}
Was this page helpful?
0 / 5 - 0 ratings