oskarstark/env-var-extension

A Twig extension to access env variables

1.1.3 2022-03-02 13:07 UTC

This package is auto-updated.

Last update: 2024-04-24 13:31:21 UTC


README

This library provides methods to use environment variables in Twig templates.

CI

Installation

composer require oskarstark/env-var-extension
# config/services.yaml
services:
    OskarStark\Twig\EnvVarExtension:
        tags: ['twig.extension']

Usage

To access the value of an existing environment variable BRANCH_NAME=develop

{{ env(BRANCH_NAME) }} # prints 'develop'

You can also check if an envirnment variable exists:

{{ has_env(BRANCH_NAME) }} # returns: true