PHPackages                             xeriab/konfig - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. xeriab/konfig

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

xeriab/konfig
=============

Yet another simple configuration loader library.

0.2.6(9y ago)5192MITPHPPHP &gt;=5.6.0

Since Mar 8Pushed 9y ago2 watchersCompare

[ Source](https://github.com/xeriab/konfig)[ Packagist](https://packagist.org/packages/xeriab/konfig)[ Docs](http://xeriab.github.io/projects/konfig/)[ RSS](/packages/xeriab-konfig/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (10)Dependencies (6)Versions (14)Used By (0)

Konfig
------

[](#konfig)

###### Yet another simple configuration loader library.

[](#yet-another-simple-configuration-loader-library)

[![Latest Version](https://camo.githubusercontent.com/21fee01100c1fba32b8672fa1db5c4c06001501fbaf34db9a9434c212e9cf016/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7865726961622f6b6f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xeriab/konfig)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://xeriab.mit-license.org)[![Build Status](https://camo.githubusercontent.com/7d66d4505227344492d4b48cb5b04d0a9ff75634cde324557d8ff545f948d59e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7865726961622f6b6f6e6669672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/xeriab/konfig)[![Coverage Status](https://camo.githubusercontent.com/e4a418d350e691d96168dfb725cb16e1a6eff17f5eb83f8afbe3a7628034f2ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7865726961622f6b6f6e6669672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xeriab/konfig/code-structure)[![Quality Score](https://camo.githubusercontent.com/e6ed824d9187b6b9304c678612915ae8a7b131f24550e09704a8d92d22872c4b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7865726961622f6b6f6e6669672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xeriab/konfig)[![Total Downloads](https://camo.githubusercontent.com/1f6c7cbc6bc1d31279863811c0ccec4d8d74405224fa8a8489d0d3c9c1179d66/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7865726961622f6b6f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xeriab/konfig)

**Konfig** is a simple configuration loader library that supports `INI`, `JSON`, `NEON`, `PHP`, `TOML`, `XML`, `Java-Properties` and `YML/YAML` files.

### REQUIREMENTS

[](#requirements)

Konfig requires `PHP 5.6+` and suggests using [Yosymfony Toml Parser](https://github.com/yosymfony/Toml), [Nette NEON](https://github.com/nette/neon) and [PHP YAML](https://secure.php.net/manual/en/book.yaml.php) or [Symfony YAML](https://github.com/symfony/Yaml).

### INSTALLATION

[](#installation)

The supported way of installing **Konfig** is via Composer.

```
$ composer require xeriab/konfig
```

### USAGE

[](#usage)

**Konfig** is designed with simplicity in mind and it is lightweight and straightforward to use. All you can do with it is load, get, set and delete.

### LOADING FILES

[](#loading-files)

The `Konfig` object can be created via the factory method `load()`, or by direct instantiation:

```
use Exen\Konfig\Konfig;

// Load a single file
$config = Konfig::load('konfig.json');
$config = new Konfig('konfig.json');

// Load values from multiple files
$config = new Konfig(['konfig.json', 'konfig.xml']);

// Load all supported files in a directory
$config = new Konfig(__DIR__ . '/konfig');

// Load values from optional files
$config = new Konfig(['konfig.dist.json', 'konfig.json']);
```

Files are parsed and loaded depending on the file extension.

**NOTE**: When loading multiple files, entries with ***duplicate keys*** will take on the value from the last loaded file.

**NOTE**: When loading a directory, the path is `glob`ed and files are loaded in by name alphabetically.

### GETTING VALUES

[](#getting-values)

Getting values can be done in three ways. One, by using the `get()` method:

```
// Get value using key
$debug = $config->get('debug');

// Get value using nested key
$secret = $config->get('security.secret');

// Get a value with a fallback
$ttl = $config->get('app.timeout', 3000);
```

The second method, is by using it like an array:

```
// Get value using a simple key
$debug = $config['debug'];

// Get value using a nested key
$secret = $config['security.secret'];

// Get nested value like you would from a nested array
$secret = $config['security']['secret'];
```

The third method, is by using the `all()` method:

```
// Get all values
$data = $config->all();
```

### SETTING VALUES

[](#setting-values)

Although Konfig supports setting values via `set()` or, via the array syntax, **any changes made this way are NOT reflected back to the source files**. By design, if you need to make changes to your configuration files, you have to do it manually.

```
$config = Konfig::load('konfig.json');

// Sample value from our konfig file
assert($config['secret'] == '123');

// Update konfig value to something else
$config['secret'] = '456';

// Reload the file
$config = Konfig::load('konfig.json');

// Same value as before
assert($config['secret'] == '123');

// This will fail
assert($config['secret'] == '456');
```

### USING WITH DEFAULT VALUES

[](#using-with-default-values)

Sometimes in your own projects you may want to use Konfig for storing application settings, without needing file I/O. You can do this by extending the `AbstractKonfig` class and populating the `getDefaults()` method:

```
use Exen\Konfig\AbstractKonfig;

class MyKonfig extends AbstractKonfig
{
    protected function getDefaults()
    {
        return [
            'host' => 'localhost',
            'port' => 80,
            'servers' => [
                'host1',
                'host2',
                'host3',
            ],
            'app' => [
                'name' => 'konfig',
                'secret' => 'secret',
            ],
        ];
    }
}
```

### EXAMPLES OF SUPPORTED CONFIGURATION FILES

[](#examples-of-supported-configuration-files)

Examples of simple, valid configuration files can be found [here](tests/mocks/pass).

### CHANGELOG

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for details.

### TESTING

[](#testing)

```
$ phpunit
```

### CONTRIBUTING

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### CREDITS

[](#credits)

- [Xeriab Nabil](https://github.com/xeriab)

### CONTRIBUTORS

[](#contributors)

- [Nashwan Doaqan](https://github.com/nash-ye)

### LICENSE

[](#license)

The MIT License (MIT). Please see [License](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~1 days

Total

13

Last Release

3587d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

0.1.2PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/991e6fbcd995c4ea7af220143d495a67c5be6762dca9101eae54a1c5eb1b3d74?d=identicon)[xeriab](/maintainers/xeriab)

---

Top Contributors

[![xeriab](https://avatars.githubusercontent.com/u/239760?v=4)](https://github.com/xeriab "xeriab (157 commits)")[![nash-ye](https://avatars.githubusercontent.com/u/4238321?v=4)](https://github.com/nash-ye "nash-ye (9 commits)")

---

Tags

jsonconfigurationxmlconfigyamlymlneonpropertiesinitoml

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/xeriab-konfig/health.svg)

```
[![Health](https://phpackages.com/badges/xeriab-konfig/health.svg)](https://phpackages.com/packages/xeriab-konfig)
```

###  Alternatives

[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97413.9M195](/packages/hassankhan-config)[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

69124.3k1](/packages/m1-vars)[thewunder/conphigure

Framework Agnostic Configuration Library

3121.7k](/packages/thewunder-conphigure)[yosymfony/config-loader

Configuration file loader

10112.5k3](/packages/yosymfony-config-loader)[davidepastore/slim-config

A slim middleware to read configuration from different files based on hassankhan/config

359.3k1](/packages/davidepastore-slim-config)[phppkg/config

Config manage, load, get. Supports INI,JSON,YAML,NEON,PHP format file

133.5k](/packages/phppkg-config)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
