slince/config

A flexible configuration file loader that supports multiple file formats

1.1.0 2017-05-07 08:23 UTC

This package is auto-updated.

Last update: 2024-12-08 18:31:14 UTC


README

Build Status Coverage Status Latest Stable Version Scrutinizer

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