class DotenvManager

Properties

static protected null|array<string, null|string> $cachedValues

The keys and values loaded from the last load/reload call.

Methods

static array
getLoadedVariableNames()

Get the names loaded from dotenv, excluding external environment variables.

static void
load(array $paths, string|null $name = null)

Load environment variables from the given paths.

static void
safeLoad(array $paths, string|null $name = null)

Load environment variables, ignoring missing files.

static void
reload(array $paths, string|null $name = null)

Reload environment variables from the given paths.

static Dotenv
createDotenv(array $paths, string|null $name = null)

Create a Dotenv instance using Env's repository.

static void
flushState()

Flush all static state.

Details

at line 24
static array getLoadedVariableNames()

Get the names loaded from dotenv, excluding external environment variables.

Return Value

array

at line 38
static void load(array $paths, string|null $name = null)

Load environment variables from the given paths.

This is a one-shot method — subsequent calls return early if values have already been loaded. Use reload() to re-read the env file.

Loaded values and the one-shot cache persist for the worker lifetime and affect every subsequent request.

Parameters

array $paths
string|null $name

Return Value

void

at line 58
static void safeLoad(array $paths, string|null $name = null)

Load environment variables, ignoring missing files.

Same one-shot semantics as load(), but uses Dotenv's safeLoad() which returns an empty array if the file doesn't exist instead of throwing. InvalidFileException is still thrown for malformed files.

Loaded values and the one-shot cache persist for the worker lifetime and affect every subsequent request.

Parameters

array $paths
string|null $name

Return Value

void

at line 79
static void reload(array $paths, string|null $name = null)

Reload environment variables from the given paths.

Deletes previously loaded env vars from putenv, resets the Env repository's ImmutableWriter so it treats all keys as writable, then safely re-reads the env file. A missing file publishes an empty environment instead of retaining values from the previous load.

Reloading mutates process-global environment values observed by every concurrent and subsequent request in the worker.

Parameters

array $paths
string|null $name

Return Value

void

at line 95
static protected Dotenv createDotenv(array $paths, string|null $name = null)

Create a Dotenv instance using Env's repository.

Parameters

array $paths
string|null $name

Return Value

Dotenv

at line 103
static void flushState()

Flush all static state.

Return Value

void