DotenvManager
class DotenvManager
Properties
| static protected null|array<string, null|string> | $cachedValues | The keys and values loaded from the last load/reload call. |
Methods
Get the names loaded from dotenv, excluding external environment variables.
Load environment variables from the given paths.
Load environment variables, ignoring missing files.
Reload environment variables from the given paths.
Create a Dotenv instance using Env's repository.
Flush all static state.
Details
at line 24
static array
getLoadedVariableNames()
Get the names loaded from dotenv, excluding external environment variables.
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.
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.
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.
at line 95
static protected Dotenv
createDotenv(array $paths, string|null $name = null)
Create a Dotenv instance using Env's repository.
at line 103
static void
flushState()
Flush all static state.