Config
Config
Application 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
overridePaths
public array $overridePaths
instances
private array $instances
env
private string $env
source
private string $source
sourceFile
public string $sourceFile
global
private array $global
loaded
private bool $loaded
secureKeys
private array $secureKeys
includes
private array $includes
Methods
__construct
protected __construct({Array})
The 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 values | | $pathType
| string
| the search path type to look for configuration files | | $overrideNamespaces
| bool
| |
__toString
Output the configuration in a human readable format.
public __toString({Array})
This method is useful for logging, debugging or for using in application administration interfaces to check the current running configuration.
Example Output
app.name = Example Application app.version = 0.0.1 app.layout = application app.theme.name = test app.defaultController = Index app.debug = 1 paths.model = models paths.view = views paths.controller = controllers php.date.timezone = Australia/ACT php.display_startup_errors = 1 php.display_errors = 1 module.require[] = pgsql
getInstance
public getInstance({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$sourceFile | string | |
$env | string | |
$defaults | array | |
$pathType | string | |
$overrideNamespaces | bool |
load
Loads a configuration file and returns the configuration options.
public load({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$source | string | the name of the configuration file to load |
$defaults | array | (optional) The default configuration options |
$pathType | string | (optional) The type of path to use for loading the file |
$overridePaths | array | (optional) An array of override paths to search for the file |
$overrideNamespaces | bool | (optional) Whether to override namespaces when searching for the file |
loaded
Check whether the config was loaded from the source file.
public loaded({Array})
getEnv
Get the config environment that was loaded.
public getEnv({Array})
getEnvConfig
Retrieves the environment configuration array.
public getEnvConfig({Array})
This 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({Array})
toString
Converts the configuration object to a string representation.
public toString({Array})
parseString
Parses a string by replacing placeholders with their corresponding values.
public parseString({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$elem | mixed | the string to be parsed |
$key | string | the key used for parsing the string |
toSecureArray
Converts the configuration object to a secure array by removing the secure keys.
public toSecureArray({Array})
save
public save({Array})
loadSourceFile
Loads the configuration file from the given source.
private loadSourceFile({Array})
Parameters
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})
Parameters
Parameter | Type | Description |
---|---|---|
$options | array | the array of configuration options |
$config | Map | the Map object to store the configuration options |
$env | string | The environment to load the configuration for. If null, the default environment will be used. |
Generated by Hazaar API Doc Generator