Config Component
, (*1)
Config Component is a file configuration loader and saver that supports PHP, XML, JSON, and YAML files., (*2)
Requirements
Installation
$ composer require kasseler/config
Usage
Initialization Yaml configuration, (*3)
$config = new Repository(new YamlFileReader(), new YamlFileWriter(), __DIR__.'/app/config/');
Initialization XML configuration, (*4)
$config = new Repository(new XmlFileReader(), new XmlFileWriter(), __DIR__.'/app/config/');
Initialization JSON configuration, (*5)
$config = new Repository(new JsonFileReader(), new JsonFileWriter(), __DIR__.'/app/config/');
Initialization PHP array configuration, (*6)
$config = new Repository(new ArrayFileReader(), new ArrayFileWriter(), __DIR__.'/app/config/');
$config
->set('database.host', 'localhost')
->set('database.user', 'root')
->set('database.password', '')
->set('database.database', 'config')
->write();
$config->get('database.host');