NanoFramework 1.4.0
A tiny PHP Framework
All Data Structures Namespaces Files Functions Variables Pages
Static Public Member Functions | Static Protected Attributes
DotEnv Class Reference

Manages constants. More...

Static Public Member Functions

static setRoot (string $root)
 
static getRoot ()
 
static load ()
 
static getEnv (string $key)
 
static setEnv (string $key, string $value)
 

Static Protected Attributes

static $root = './'
 
static array $data = []
 

Detailed Description

Manages constants.

All constants can either be defined in the .env file (see dotEnvSyntax for more information) or using DotEnv::setEnv().

Definition at line 10 of file DotEnv.php.

Member Function Documentation

◆ getEnv()

static getEnv ( string  $key)
static

This method returns the value associated to the given key or the default value if not found.

Parameters
string$keythe key to look for
Returns
null|string The value associated to the key or null if not found

Definition at line 74 of file DotEnv.php.

◆ getRoot()

static getRoot ( )
static

This retrieves the current root directory where the .env file is located.

Returns
string The current root directory

Definition at line 40 of file DotEnv.php.

◆ load()

static load ( )
static

This method opens the .env file at the current root if it exists and loads all the data.

Definition at line 48 of file DotEnv.php.

◆ setEnv()

static setEnv ( string  $key,
string  $value 
)
static

This method sets a new value for the given key.

Parameters
string$keythe key to set the value to
string$valuethe value to memorize

Definition at line 89 of file DotEnv.php.

◆ setRoot()

static setRoot ( string  $root)
static

The root where to find the .env file can be changed with this method.

Parameters
string$rootthe new root directory

Definition at line 27 of file DotEnv.php.

Field Documentation

◆ $data

array $data = []
staticprotected

The list of all constants known to DotEnv.

Definition at line 20 of file DotEnv.php.

◆ $root

$root = './'
staticprotected

The directory where to find the .env file.

Definition at line 15 of file DotEnv.php.


The documentation for this class was generated from the following file: