slince / config
A flexible configuration file loader that supports multiple file formats
Installs: 1 591
Dependents: 6
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.5.9
Requires (Dev)
- phpunit/phpunit: ^4.0
Suggests
- openlss/lib-array2xml: requires for parsing xml file
- symfony/yaml: Requires for parsing yaml file
This package is auto-updated.
Last update: 2024-10-08 18:09:03 UTC
README
The library support multiple configuration file formats like json,ini,xml,yaml and native php array. It can also help to dump items to the specified configuration file.
Installation
Install via composer
{ "require": { "slince/config": "^1.0" } }
Usage
Creates a config instance
$config = new Slince\Config\Config();
Load configuration files
Loads a configuration file
$config->load('/path/to/config.json');
Loads a directory that contains multiple files
$config->load('/path/to/config-directory/');
Notes: The directory can't contain unsupported files.
Access data
$config->get('foo'); //Or access the data like array $config['foo']['bar'];
Checks whether a item exists by its key
echo $config->exists('foo'); //or like array echo isset($config['foo']);
Adds a item to the container
$config->set('bar', 'baz'); //or like array $config['bar'] = 'baz';
Removes a item by its key
$config->delete('bar'); //or like array unset($config['bar']);
Removes all items
$config->clear();
Dumps all items to an specified configuration file
$config->dump('/path/to/config-dump.php');
License
The MIT license. See MIT