Config class for managing application configurations.
Examples:
// Initialize Config with a specific directory
$config = new Yohns\Core\Config(__DIR__.'/../config');
// Get a configuration value
$dbHost = Yohns\Core\Config::get('db_host', 'database');
// Set a custom configuration value
Yohns\Core\Config::set('api_key', '12345');
// Retrieve a custom configuration value
$apiKey = Yohns\Core\Config::getCustom('api_key');
// Reload configurations from a different directory
Yohns\Core\Config::reload('/new/path/to/config');
Name | Description |
---|---|
__construct | Config constructor. |
get | Retrieves a configuration value. |
getAll | Retrieve all configuration values for file. |
getCustom | Retrieves a custom configuration value. |
reload | Reloads configurations from a specified directory. |
set | Sets a configuration value. |
Description
public __construct (string $directory)
Config constructor.
Parameters
(string) $directory
: Path to the directory containing configuration files.
Return Values
void
Throws Exceptions
\InvalidArgumentException
if the directory does not exist or is not readable.
Description
public static get (string $key, string $configFile)
Retrieves a configuration value.
Parameters
(string) $key
: The key of the configuration to retrieve.(string) $configFile
: The configuration file identifier.
Return Values
mixed
The value of the configuration, or null if not found.
Description
public static getAll (string $configFile)
Retrieve all configuration values for file.
Parameters
(string) $configFile
: The configuration file identifier.
Return Values
mixed
The value of the configuration, or null if not found.
Description
public static getCustom (string $key)
Retrieves a custom configuration value.
Parameters
(string) $key
: The key of the custom configuration to retrieve.
Return Values
mixed
The value of the custom configuration, or null if not found.
Description
public static reload (string $directory)
Reloads configurations from a specified directory.
Parameters
(string) $directory
: Directory path to reload configuration files from.
Return Values
void
Description
public static set (string $key, mixed $value, string $configFile)
Sets a configuration value.
Parameters
(string) $key
: The key of the configuration to set.(mixed) $value
: The value to assign to the configuration.(string) $configFile
: The configuration file identifier.
Return Values
void