Attention

TYPO3 v9 has reached its end-of-life September 30th, 2021 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

You can order Extended Long Term Support (ELTS) here: TYPO3 ELTS.

getEnv

Allows to override static values with environment variables.

The modifier checks if the variable given as its argument is set and reads the value if so, overriding any existing value. If the environment variable is not set, the variable given on the left-hand side of the expression is not changed.

To have a value actually inserted, your PHP execution environment (webserver, PHP-FPM) needs to have these variables set, or you need a mechanism like dotenv to set them in your running TYPO3.

As it is a syntax feature you can use it in both constants and setup plus it gets cached, as opposed to the getText.getenv feature.

Example

# Define default value
myConstant = defaultValue
# Enable overriding by environment variable
myConstant := getEnv(TS_MYCONSTANT)