Config
Config
Configuration Class.
The config class loads settings from a configuration file and configures the system ready for the application to run. By default the config file used is application.ini and is stored in the config folder of the application path.
Properties
supportedExtensions
private array $supportedExtensions = array (
0 => 'json',
1 => 'ini',
2 => 'php',
)overridePaths
private array $overridePathsinstances
private array $instancesenv
private string $envbasePath
private string $basePathsourceFile
public string $sourceFileglobal
private array $globalsecureKeys
private array $secureKeysincludes
private array $includesoptions
The configuration options for the selected environment.
private array $optionsMethods
__construct
public __construct(?string $sourceFile, ?string $env, ?array $defaults): voidThe application configuration constructor loads the settings from the configuration file specified in the first parameter. It will use the second parameter as the starting point and is intended to allow different operating environments to be configured from a single configuration file.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sourceFile | string | The absolute path to the config file |
$env | string | The application environment to read settings for. Usually development or production. |
$defaults | array | initial defaut values9 |
setEnvironment
Set the environment for the configuration.
public setEnvironment(string $env): voidParameters
| Parameter | Type | Description |
|---|---|---|
$env | string | The environment to set |
getEnvironment
Get the config environment that was loaded.
public getEnvironment(): stringsetBasePath
Set the base path for the configuration.
public setBasePath(string $path): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
getBasePath
Get the base path for the configuration.
public getBasePath(): stringsetOverridePaths
Set the source file for the configuration.
public setOverridePaths(array $paths): voidParameters
| Parameter | Type | Description |
|---|---|---|
$paths | array | The paths to search for the configuration file overrides |
loadFromFile
Loads a configuration file and returns the configuration options.
public loadFromFile(string $source, ?array $defaults): boolParameters
| Parameter | Type | Description |
|---|---|---|
$source | string | the name of the configuration file to load |
$defaults | array | (optional) The default configuration options |
loadFromArray
Loads the configuration options from an array.
public loadFromArray(array $options, ?array $defaults): boolParameters
| Parameter | Type | Description |
|---|---|---|
$options | array | The configuration options to load |
$defaults | array | (optional) The default configuration options |
getEnvConfig
Retrieves the environment configuration array.
public getEnvConfig(?string $env): voidThis method returns the configuration array for the specified environment. If no environment is specified, it uses the default environment set in the application.
Parameters
| Parameter | Type | Description |
|---|---|---|
$env | string | The environment for which to retrieve the configuration. Defaults to null. |
getEnvironments
Get the list of environments defined in the configuration.
public getEnvironments(): voidtoString
Converts the configuration object to a string representation.
public toString(): stringtoSecureArray
Converts the configuration object to a secure array by removing the secure keys.
public toSecureArray(): voidget
public get(string $key): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$key | string |
save
public save(): booloffsetExists
public offsetExists(mixed $offset): boolParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
offsetGet
public offsetGet(mixed $offset): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
offsetSet
public offsetSet(mixed $offset, mixed $value): voidParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed | |
$value | mixed |
offsetUnset
public offsetUnset(mixed $offset): voidParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
toArray
Converts the configuration object to an array.
public toArray(): voidcurrent
public current(): mixednext
public next(): voidkey
public key(): mixedvalid
public valid(): boolcount
public count(): intrewind
public rewind(): voidextend
Extends the configuration options with the given configuration array.
public extend(array $config): voidThis method merges the given configuration array with the existing configuration options.
Parameters
| Parameter | Type | Description |
|---|---|---|
$config | array | the configuration array to extend the existing configuration options |
loadSourceFile
Loads the configuration file from the given source.
private loadSourceFile(string $source): voidParameters
| Parameter | Type | Description |
|---|---|---|
$source | string | the path to the configuration file |
loadConfigOptions
Loads the configuration options into the provided Map object based on the given options array and environment.
private loadConfigOptions(array $config, array $globalOptions, ?string $env): voidParameters
| Parameter | Type | Description |
|---|---|---|
$config | array | the config to store the configuration options |
$globalOptions | array | the global options to load the configuration from |
$env | string | The environment to load the configuration for. If null, the default environment will be used. |
Generated by Hazaar API Doc Generator on Mon, 27 Oct 2025 13:01:29 +0000