Config
extends Config
in package
Alias
Table of Contents
- CONFIG_CACHE_FILE = BASE_PATH . '/storage/cache/config/config.json'
- The path of the cached configuration file.
- CONFIG_DIR = BASE_PATH . '/config'
- The default directory of the configuration files.
- ON_CACHE = 'config.on.cache'
- This event will be dispatched when the config is cached.
- ON_CLEAR_CACHE = 'config.on.clearCache'
- This event will be dispatched when the config cache is cleared.
- ON_LOAD = 'config.on.load'
- This event will be dispatched when the config is loaded.
- $config : array<string|int, mixed>
- The currently loaded configuration.
- __construct() : mixed
- __toString() : mixed
- cache() : void
- Caches the current configuration as JSON. Note that a new version will not be generated unless the cache is cleared.
- clearCache() : void
- Deletes the cached configuration JSON and resets class internal state.
- get() : mixed
- Gets a value of a key from the configuration via dot-notation.
- getAll() : array<string|int, mixed>
- Returns the currently loaded configuration.
- getReference() : array<string|int, mixed>
- Returns a referenced to the current configuration array.
- has() : bool
- Checks whether a value of a key exists in the configuration via dot-notation.
- set() : void
- Sets a value of a key in the configuration via dot-notation.
- load() : void
- Loads the configuration (directly or when available from cache) and sets class internal state.
- include() : array<string|int, mixed>
- Includes all files in a directory.
- parse() : array<string|int, mixed>
- Parses the configuration to replace reference of some `{filename.config.varName}` with actual value from the passed configuration.
Constants
CONFIG_CACHE_FILE
The path of the cached configuration file.
public
string
CONFIG_CACHE_FILE
= BASE_PATH . '/storage/cache/config/config.json'
CONFIG_DIR
The default directory of the configuration files.
public
string
CONFIG_DIR
= BASE_PATH . '/config'
ON_CACHE
This event will be dispatched when the config is cached.
public
string
ON_CACHE
= 'config.on.cache'
This event will not be passed any arguments.
ON_CLEAR_CACHE
This event will be dispatched when the config cache is cleared.
public
string
ON_CLEAR_CACHE
= 'config.on.clearCache'
This event will not be passed any arguments.
ON_LOAD
This event will be dispatched when the config is loaded.
public
string
ON_LOAD
= 'config.on.load'
This event will be passed a reference to the config array.
Properties
$config
The currently loaded configuration.
protected
static array<string|int, mixed>
$config
Methods
__construct()
public
__construct() : mixed
Return values
mixed —__toString()
public
__toString() : mixed
Return values
mixed —cache()
Caches the current configuration as JSON. Note that a new version will not be generated unless the cache is cleared.
public
static cache() : void
Return values
void —clearCache()
Deletes the cached configuration JSON and resets class internal state.
public
static clearCache() : void
Return values
void —get()
Gets a value of a key from the configuration via dot-notation.
public
static get(string $key[, mixed $fallback = null ]) : mixed
Parameters
- $key : string
-
The dotted key representation.
- $fallback : mixed = null
-
[optional] The default fallback value.
Return values
mixed —The requested value or null.
getAll()
Returns the currently loaded configuration.
public
static getAll() : array<string|int, mixed>
Return values
array<string|int, mixed> —getReference()
Returns a referenced to the current configuration array.
public
static getReference() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —has()
Checks whether a value of a key exists in the configuration via dot-notation.
public
static has(string $key) : bool
Parameters
- $key : string
-
The dotted key representation.
Return values
bool —set()
Sets a value of a key in the configuration via dot-notation.
public
static set(string $key, mixed $value) : void
Parameters
- $key : string
-
The dotted key representation.
- $value : mixed
-
The value to set.
Return values
void —load()
Loads the configuration (directly or when available from cache) and sets class internal state.
protected
static load() : void
Return values
void —include()
Includes all files in a directory.
private
static include(string $path) : array<string|int, mixed>
Parameters
- $path : string
Return values
array<string|int, mixed> —parse()
Parses the configuration to replace reference of some `{filename.config.varName}` with actual value from the passed configuration.
private
static parse(array<string|int, mixed> $config) : array<string|int, mixed>
Parameters
- $config : array<string|int, mixed>