Documentation

Dotenv
in package

This is the dotenv class.

It's responsible for loading a .env file in the given directory and setting the environment vars.

Table of Contents

$filePath  : string
The file path.
$loader  : Loader|null
The loader instance.
__construct()  : void
Create a new dotenv instance.
getEnvironmentVariableNames()  : array<string|int, mixed>
Get the list of environment variables declared inside the 'env' file.
load()  : array<string|int, mixed>
Load environment file in given directory.
overload()  : array<string|int, mixed>
Load environment file in given directory.
required()  : Validator
Required ensures that the specified variables exist, and returns a new validator object.
safeLoad()  : array<string|int, mixed>
Load environment file in given directory, suppress InvalidPathException.
getFilePath()  : string
Returns the full path to the file.
loadData()  : array<string|int, mixed>
Actually load the data.

Properties

$filePath

The file path.

protected string $filePath

Methods

__construct()

Create a new dotenv instance.

public __construct(string $path[, string $file = '.env' ]) : void
Parameters
$path : string
$file : string = '.env'
Return values
void

getEnvironmentVariableNames()

Get the list of environment variables declared inside the 'env' file.

public getEnvironmentVariableNames() : array<string|int, mixed>
Return values
array<string|int, mixed>

required()

Required ensures that the specified variables exist, and returns a new validator object.

public required(string|array<string|int, string> $variable) : Validator
Parameters
$variable : string|array<string|int, string>
Return values
Validator

safeLoad()

Load environment file in given directory, suppress InvalidPathException.

public safeLoad() : array<string|int, mixed>
Tags
throws
InvalidFileException
Return values
array<string|int, mixed>

getFilePath()

Returns the full path to the file.

protected getFilePath(string $path, string $file) : string
Parameters
$path : string
$file : string
Return values
string

loadData()

Actually load the data.

protected loadData([bool $overload = false ]) : array<string|int, mixed>
Parameters
$overload : bool = false
Tags
throws
InvalidPathException|InvalidFileException
Return values
array<string|int, mixed>

Search results