Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slince/config
:bamboo: A flexible configuration file loader that supports multiple file formats
https://github.com/slince/config
config config-management configuration ini ini-parser json php xml yaml yml
Last synced: 4 months ago
JSON representation
:bamboo: A flexible configuration file loader that supports multiple file formats
- Host: GitHub
- URL: https://github.com/slince/config
- Owner: slince
- Created: 2014-08-19T10:04:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T03:39:19.000Z (over 7 years ago)
- Last Synced: 2024-09-30T08:03:42.165Z (4 months ago)
- Topics: config, config-management, configuration, ini, ini-parser, json, php, xml, yaml, yml
- Language: PHP
- Homepage:
- Size: 64.5 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Configuration File Loader
[![Build Status](https://img.shields.io/travis/slince/config/master.svg?style=flat-square)](https://travis-ci.org/slince/config)
[![Coverage Status](https://img.shields.io/codecov/c/github/slince/config.svg?style=flat-square)](https://codecov.io/github/slince/config)
[![Latest Stable Version](https://img.shields.io/packagist/v/slince/config.svg?style=flat-square&label=stable)](https://packagist.org/packages/slince/config)
[![Scrutinizer](https://img.shields.io/scrutinizer/g/slince/config.svg?style=flat-square)](https://scrutinizer-ci.com/g/slince/config/?branch=master)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
```json
{
"require": {
"slince/config": "^1.0"
}
}
```### Usage
#### Creates a config instance
```php
$config = new Slince\Config\Config();
```#### Load configuration files
Loads a configuration file
```php
$config->load('/path/to/config.json');
```Loads a directory that contains multiple files
```php
$config->load('/path/to/config-directory/');
```
> Notes: The directory can't contain unsupported files.### Access data
```php
$config->get('foo');//Or access the data like array
$config['foo']['bar'];
```Checks whether a item exists by its key
```php
echo $config->exists('foo');//or like array
echo isset($config['foo']);
```Adds a item to the container
```php
$config->set('bar', 'baz');//or like array
$config['bar'] = 'baz';
```Removes a item by its key
```php
$config->delete('bar');//or like array
unset($config['bar']);
```Removes all items
```php
$config->clear();
```#### Dumps all items to an specified configuration file
```php
$config->dump('/path/to/config-dump.php');
```### License
The MIT license. See [MIT](https://opensource.org/licenses/MIT)