class Env

Class Env

Handles loading and retrieving environment variables from a .env file.

Methods

static void
load(string $file)

Loads environment variables from a .env file.

static mixed
get(string $key, mixed $default = null)

Retrieves an environment variable.

Details

at line 28
static void load(string $file)

Loads environment variables from a .env file.

This method reads the given file, parses the key-value pairs, and stores them in the $variables array. It also ensures that boolean and numeric values are converted appropriately.

Parameters

string $file

Path to the .env file.

Return Value

void

at line 88
static mixed get(string $key, mixed $default = null)

Retrieves an environment variable.

Looks up the requested key in the loaded environment variables. Returns the corresponding value or the specified default value if the key does not exist.

Parameters

string $key

The environment variable key.

mixed $default

The default value to return if the key is not found.

Return Value

mixed

The value of the environment variable or the default value.