tacoberu / php-config
Config libs provides interface for loading config. Local, User-base, System-base, App-base.
dev-master
2018-04-14 01:42 UTC
Requires
- php: >=5.3.3
- nette/utils: ^2.4
Requires (Dev)
- php: >=5.3.0
- janmarek/mockista: ^1.1
- phpunit/phpunit: ~4.0
- tracy/tracy: ^2.3
This package is auto-updated.
Last update: 2024-11-17 23:44:46 UTC
README
Config libs provides interface for loading config. Local, User-base, System-base, App-base.
Use case
$config = Config::createByEnvironment('doe', null, getcwd()); // doe is application name
$config->has('name'); // true
$config->required('name'); // John
$config->required('core.name'); // Andrey
$config->required('lang[5].name'); // germany
$config->required('lang[de].name'); // germany
$config->required('core'); // [ name => Andrey, age => 42 ]
$config->required('nope'); // exception
$config->get('nope'); // NULL
$config->get('nope', 'Mark'); // Mark
Default configuration
$config = Config::createByEnvironment('doe', __dir__ . '/default.json', getcwd());
Own Parser
$config = Config::createByEnvironment('doe', __dir__ . '/default.xml', getcwd());
$config->addParser(new XmlParser);
Source of configuration
Configuration is loading from:
system:
- Linux: /etc/doe.ini
- MacOS: /private/etc/doe.ini
- Win: ?
user:
- Linux: /home/current-user/.config/doe/config.ini
- MacOS: /Users/current-user/.config/doe/config.ini
- Win: ?
local:
./doe.ini
Buildin format
- ini
- json
TODO
- own loader
- include
- merge parent