oskarstark / env-var-extension
A Twig extension to access env variables
Installs: 87 009
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- twig/twig: ^2.6 || ^3.0
Requires (Dev)
- ergebnis/test-util: ^1.4
- friendsofphp/php-cs-fixer: ^2.18.3
- phpstan/phpstan: ^0.12.82
- phpunit/phpunit: ^8.5 || ^9.0
README
This library provides methods to use environment variables in Twig templates.
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