class EnvFile (View source)

Constants

SOURCE_VAR

SOURCE_ENV

SOURCE_APACHE

SOURCE_APACHE_ALL

REGEX_ENTRY

REGEX_KEY

Methods

__construct(string $path)

Load variable from .env or from cache (if avaliable)

setOverride($enable)

This method affect fill() and storeAsVars() methods

refresh()

Refresh entries from the env file values.

fill(int $sources = self::SOURCE_VAR)

Fill the values of environment variables

bool
storeAsArray(string $path)

Store entries as PHP array

bool
storeAsVars(string $path)

Store entries as $_ENV[] = ; in a PHP script

__set(string $name, string|null $value)

Magic method for set a manual entry

string
__get(string $name)

Magic method for get specific entry

Details

__construct(string $path)

Load variable from .env or from cache (if avaliable)

Parameters

string $path

Env file path

Exceptions

Exception

setOverride($enable)

This method affect fill() and storeAsVars() methods

Parameters

$enable

Exceptions

Exception

refresh()

Refresh entries from the env file values.

Ideal for use before fill() or cache(), especially if there are any changes to the file.

Exceptions

Exception

fill(int $sources = self::SOURCE_VAR)

Fill the values of environment variables

Parameters

int $sources

Defines the filling modes

Exceptions

Exception

bool storeAsArray(string $path)

Store entries as PHP array

Parameters

string $path

Return Value

bool

bool storeAsVars(string $path)

Store entries as $_ENV[] = ; in a PHP script

Parameters

string $path

Return Value

bool

__set(string $name, string|null $value)

Magic method for set a manual entry

Parameters

string $name
string|null $value

Exceptions

Exception

string __get(string $name)

Magic method for get specific entry

Parameters

string $name

Return Value

string