Documentation

Processenv
in package

Table of Contents

Properties

$env  : array<string|int, mixed>
store the `.env`, `$_ENV` array
$options  : ProcessenvOptions
store options value

Methods

__construct()  : mixed
Option to add .env to global $_ENV and/or $_SERVER
__get()  : stdClass|string|array<string|int, mixed>
magic method to parse as object
load()  : void
load and parse environment File configure the parser and initialize processenv()
processenv()  : stdClass|string|array<string|int, mixed>
get environment key
get()  : stdClass|string|array<string|int, mixed>
get ´.env´ and ´$_ENV´ value if exists else get empty string
getAll()  : array<string|int, mixed>
get all ´.env´ and ´$_ENV´ values
configure()  : void
Configure options
filterEmptyLinesAndCommentLines()  : array<string|int, mixed>
filter line breaks from Array
filterInlineComments()  : string
filter inline comments after escaped hashtag
getEnvironmentFileContent()  : array<string|int, mixed>
get .env file content
parseEnvironmentFile()  : void
parse .env file
parseNestedStrings()  : string
Parse nested string in `.env`
parseObject()  : stdClass|string|array<string|int, mixed>
parse values to Object or Array
removeQuotationMarks()  : string
remove quotation marks
setKeyValue()  : array<string|int, mixed>
Parse `.env` file and set the key => value pairs

Properties

$env

store the `.env`, `$_ENV` array

private array<string|int, mixed> $env = []

Methods

__construct()

Option to add .env to global $_ENV and/or $_SERVER

public __construct([ProcessenvOptions|null $options = null ]) : mixed

default $env = new Processenv( new ProcessenvOptions( localFirst: true, exceptions: true, globalEnv: false, globalServer: false, globalKey: false, objectParser: self::PARSE_AS_STDCLASS, replacePattern: '[:PROCESSENV_REPLACE:]' ) );

If the $globalKey option is set to true,
a key is created in the globals $_SERVERS and $_ENV
where the .env file is then initialized.

Parameters
$options : ProcessenvOptions|null = null

__get()

magic method to parse as object

public __get(string $value) : stdClass|string|array<string|int, mixed>
Parameters
$value : string
Return values
stdClass|string|array<string|int, mixed>

processenv()

get environment key

public processenv([string $value = '' ][, mixed $default = '' ]) : stdClass|string|array<string|int, mixed>
Parameters
$value : string = ''
$default : mixed = ''
Return values
stdClass|string|array<string|int, mixed>

get()

get ´.env´ and ´$_ENV´ value if exists else get empty string

protected get(string $value) : stdClass|string|array<string|int, mixed>
Parameters
$value : string
Return values
stdClass|string|array<string|int, mixed>

getAll()

get all ´.env´ and ´$_ENV´ values

protected getAll() : array<string|int, mixed>
Return values
array<string|int, mixed>

configure()

Configure options

private configure() : void

filterEmptyLinesAndCommentLines()

filter line breaks from Array

private filterEmptyLinesAndCommentLines(array<string|int, mixed> $content) : array<string|int, mixed>
Parameters
$content : array<string|int, mixed>
Return values
array<string|int, mixed>

filterInlineComments()

filter inline comments after escaped hashtag

private filterInlineComments(string $value) : string
Parameters
$value : string
Return values
string

getEnvironmentFileContent()

get .env file content

private getEnvironmentFileContent() : array<string|int, mixed>
Tags
throws
FileNotFoundException
Return values
array<string|int, mixed>

parseNestedStrings()

Parse nested string in `.env`

private parseNestedStrings(string $value, array<string|int, mixed> $tmp_array) : string
Parameters
$value : string
$tmp_array : array<string|int, mixed>
Return values
string

parseObject()

parse values to Object or Array

private parseObject(string $value) : stdClass|string|array<string|int, mixed>
Parameters
$value : string
Return values
stdClass|string|array<string|int, mixed>

removeQuotationMarks()

remove quotation marks

private removeQuotationMarks(mixed $value) : string
Parameters
$value : mixed
Return values
string

setKeyValue()

Parse `.env` file and set the key => value pairs

private setKeyValue(array<string|int, mixed> $content) : array<string|int, mixed>
Parameters
$content : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results