PHPackages                             macfja/chain-config - 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. macfja/chain-config

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

macfja/chain-config
===================

A configuration loader, where order matters.

0.1.0(10y ago)220MITPHPPHP &gt;=5.3

Since Jan 12Pushed 10y ago1 watchersCompare

[ Source](https://github.com/MacFJA/ChainConfig)[ Packagist](https://packagist.org/packages/macfja/chain-config)[ RSS](/packages/macfja-chain-config/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

ChainConfig
===========

[](#chainconfig)

A configuration loader, where order matters.

Features
--------

[](#features)

- Multiple configuration paths
- Multiple loader
    - Ini (`.ini`, `.properties`)
    - Json (`.json`)
    - Neon (`.neon`)
    - Php (`.php`)
    - Xml (`.xml`)
    - Yaml (`.yml`, `.yaml`)
- Handle `.dist` file
- Paths order matters
- Readers order matters
- Dynamic key
- Dynamic value

### The `.dist` file handling

[](#the-dist-file-handling)

When the search for the config file to load, the library check if a `.dist` exist. If it's the case, and there is no file without the `.dist` part, the file is used.

So, in this example:

```
 ├── test1.ini.dist
 ├── test2.ini
 └── test2.ini.dist

```

`test1.ini.dist` will be loaded,
but not `test2.ini.dist` because the file `test2.ini` exist. (and it's `test2.ini` that will be loaded)

### Order matters

[](#order-matters)

Configuration data are loaded in the order you define. Loader are used in the order you define.

Example:

```
├── 01-my-secondary-path/
│   └── a.php
└── 02-my-main-path/
    ├── a.ini
    ├── b.ini
    └── b.xml

```

If you define `02-my-main-path` to be the first path, and `01-my-secondary-path` as the second path. If you ask of a `a.*` configuration then the library will first load `02-my-main-path/a.php` and after `02-my-main-path/a.ini`. Later loading don't override already loaded data, later loading only add missing key/value.

The order of the reader also matter. In the previous structure, if you define the **Xml reader** before the **Ini loader**, then, if you ask a `b.*` config, the first file to be load is `02-my-main-path/b.xml` and after the `02-my-main-path/b.ini` file.

### Dynamics data

[](#dynamics-data)

The library expose two callback functionality. One for the key, the other for the value. Before the key is send to the library, it can be changed by one or more callback function. Same thing for the value, just before returning it, the library will send the value to all registered callback.

This can be useful for change a key or a value depending on another configuration or an environment depends variable. *See example below*

Installation
------------

[](#installation)

The simplest way to install the library is to use [Composer](http://getcomposer.org):

```
composer require macfja/chain-config
```

Usage
-----

[](#usage)

Create a `Config` object:

```
$config = new Config();
$config->appendPath(__DIR__ . DIRECTORY_SEPARATOR . 'config');
$config->appendReader(new IniReader());
```

Read a configuration:

```
engine = $config->get('database.engine');
```

[Detailed class API](doc/Classes/Config.md)

[Example of usage](doc/Example.md)

Reader Format
-------------

[](#reader-format)

[More information in Readers documentation](doc/Classes/Readers.md)

Limitation
----------

[](#limitation)

You can not use the directory separator (`/` on Unix/Linux, `\` on Windows) or the path separator (`:` on Unix/Linux) in the first part of the key.

Additional Classes
------------------

[](#additional-classes)

You can found two class that **ChainConfig** use to work:

- [`MacFJA\ChainConfig\Collection\MultiPartKeyArray`](doc/Classes/MultiPartKeyArray.md): The class that power the reading/writing of dot key access (and the dot is just an option!)
- [`MacFJA\ChainConfig\Collection\OrderedGroup`](doc/Classes/OrderedGroup.md): The class that power the path grouping and ordering

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3775d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e35bfbefc89c6998a77e2bf9ef3da42d80513b57cb9ae209b6c39b92a96097b3?d=identicon)[MacFJA](/maintainers/MacFJA)

---

Top Contributors

[![MacFJA](https://avatars.githubusercontent.com/u/1475671?v=4)](https://github.com/MacFJA "MacFJA (1 commits)")

---

Tags

chainconfiguration-loaderorderjsonconfigurationxmlyamlneonChaininiLoad Priority

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/macfja-chain-config/health.svg)

```
[![Health](https://phpackages.com/badges/macfja-chain-config/health.svg)](https://phpackages.com/packages/macfja-chain-config)
```

###  Alternatives

[hassankhan/config

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

97513.5M170](/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.2k1](/packages/m1-vars)[thewunder/conphigure

Framework Agnostic Configuration Library

3115.9k](/packages/thewunder-conphigure)[davidepastore/slim-config

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

338.9k1](/packages/davidepastore-slim-config)

PHPackages © 2026

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