class DotenvManager

Properties

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

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

Methods

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 27
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.

Boot-only. 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 46
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.

Boot-only. 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 66
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.

Boot-only. 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 81
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 89
static void flushState()

Flush all static state.

Return Value

void