Config
Config
Application-aware configuration loader and cache.
class Config extends \Hazaar\ConfigThis class extends the base {@see \Hazaar\Config} implementation with framework-specific bootstrapping rules:
- Resolves the configuration base directory from the framework loader (
FilePath::CONFIG). - Applies the active application environment (explicit argument,
APPLICATION_ENV, ordevelopmentfallback). - Supports global override search paths via {@see self::$overridePaths}.
- Reuses previously opened configuration instances per source/environment pair.
Instances are created through {@see self::open()}, which acts as a lightweight registry to avoid repeatedly parsing the same configuration source for the same environment.
Properties
overridePaths
public array $overridePathsinstances
private array $instancesMethods
__construct
Config constructor.
protected __construct(?string $sourceFile, ?string $env, ?array $defaults): voidInitializes the configuration by setting the base path, environment, and override paths. Throws an exception if the configuration path cannot be found.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sourceFile | string | the source configuration file name or path |
$env | string | The application environment (e.g., 'development', 'production'). |
$defaults | array | optional default configuration values |
open
The application configuration constructor loads the settings from the configuration file specified
public open(?string $sourceFile = 'app', ?string $env, ?array $defaults): Configin 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 |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000