Documentation

ConfigInterface

Config handler

Loads INI files, caches the retrieved values

Table of Contents

clearCache()  : void
Clears the in-memory cache
get()  : mixed
Returns with value from the configuration
getArray()  : array<string|int, mixed>
Returns with an array from the config
getCommaSeparatedValues()  : array<string|int, mixed>
Returns with an array from a comma separated string config value
getFullPath()  : string
Replaces the ~ symbol at the beginning of the path with the `app.root_path` config value
isCached()  : bool
Returns true if the config value is cached
load()  : void
Loads an INI file and merges with current config
rootPath()  : string
Returns the application root path (`app.root_path` config value)

Methods

clearCache()

Clears the in-memory cache

public clearCache() : void
Return values
void

get()

Returns with value from the configuration

public get(string $name[, mixed $default = null ][, bool $useCache = true ]) : mixed
Parameters
$name : string

The config name

$default : mixed = null

The return value if the name does not exist in the configuration

$useCache : bool = true

Use the cache for retrieving the value?

Return values
mixed

getArray()

Returns with an array from the config

public getArray(string $prefix[, array<string|int, mixed> $default = [] ][, bool $useCache = true ]) : array<string|int, mixed>

For example: with the following config:

persons.0.name = "name1"
persons.0.age = "32"
persons.1.name = "name2"
persons.1.age = "42"

the result will be for $config->getArray('persons'):

[
  0 => [
     "name" => "name1",
     "age" => "32"
  ],
  1 => [
     "name" => "name2",
     "age" => "42"
  ]
]
Parameters
$prefix : string
$default : array<string|int, mixed> = []
$useCache : bool = true
Return values
array<string|int, mixed>

getCommaSeparatedValues()

Returns with an array from a comma separated string config value

public getCommaSeparatedValues(string $name[, bool $useCache = true ]) : array<string|int, mixed>

For example: "1, 2, 3" will result in ['1', '2', '3']

Parameters
$name : string

The config name

$useCache : bool = true

Use the cache for retrieving the value?

Return values
array<string|int, mixed>

getFullPath()

Replaces the ~ symbol at the beginning of the path with the `app.root_path` config value

public getFullPath(string $path) : string
Parameters
$path : string
Return values
string

isCached()

Returns true if the config value is cached

public isCached(string $name) : bool
Parameters
$name : string

Name of the config

Return values
bool

Is the config value cached?

load()

Loads an INI file and merges with current config

public load(string $path) : void

It does NOT process sections! The "true", "false", "no", "yes", "on", "off" values will be replaced with true and false values.

Parameters
$path : string

The path of the INI file

Return values
void

rootPath()

Returns the application root path (`app.root_path` config value)

public rootPath() : string
Return values
string

Search results