W3cubDocs

/Symfony 4.1

Dotenv

class Dotenv

Manages .env files.

Constants

VARNAME_REGEX
STATE_VARNAME
STATE_VALUE

Methods

void load(string $path, string ...$paths)

Loads one or several .env files.

void populate(array $values)

Sets values as environment variables (via putenv, $_ENV, and $_SERVER).

array parse(string $data, string $path = '.env')

Parses the contents of an .env file.

Details

void load(string $path, string ...$paths)

Loads one or several .env files.

Parameters

string $path A file to load
string ...$paths A list of additional files to load

Return Value

void

Exceptions

FormatException when a file has a syntax error
PathException when a file does not exist or is not readable

void populate(array $values)

Sets values as environment variables (via putenv, $_ENV, and $_SERVER).

Note that existing environment variables are not overridden.

Parameters

array $values An array of env variables

Return Value

void

array parse(string $data, string $path = '.env')

Parses the contents of an .env file.

Parameters

string $data The data to be parsed
string $path The original file name where data where stored (used for more meaningful error messages)

Return Value

array An array of env variables

Exceptions

FormatException when a file has a syntax error

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Dotenv/Dotenv.html