PHPackages                             helhum/config-loader - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. helhum/config-loader

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

helhum/config-loader
====================

Generic config loader with context and environment support.

v0.12.6(1y ago)308.7M↓45.6%9[1 issues](https://github.com/helhum/config-loader/issues)[1 PRs](https://github.com/helhum/config-loader/pulls)10GPL-2.0-or-laterPHPPHP &gt;=7.2CI failing

Since May 3Pushed 1y ago2 watchersCompare

[ Source](https://github.com/helhum/config-loader)[ Packagist](https://packagist.org/packages/helhum/config-loader)[ Fund](https://www.paypal.me/helhum/19.99)[ GitHub Sponsors](https://github.com/helhum)[ RSS](/packages/helhum-config-loader/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (3)Versions (23)Used By (10)

Configuration Loader [![Build Status](https://github.com/helhum/config-loader/actions/workflows/Test.yml/badge.svg)](https://github.com/helhum/config-loader/actions/workflows/Test.yml)
========================================================================================================================================================================================

[](#configuration-loader-)

This is just a class, which helps you to merge a base configuration with configuration from different contexts and the environment.

Just require it using composer: `composer require helhum/config-loader`

Basic usage
-----------

[](#basic-usage)

```
$context = 'production';
$confDir = '/path/to/conf';
$configReaderFactory = new \Helhum\ConfigLoader\ConfigurationReaderFactory($confDir);
$configLoader = new \Helhum\ConfigLoader\ConfigurationLoader(
    [
        $configReaderFactory->createReader($confDir . '/default.php'),
        $configReaderFactory->createReader($confDir . '/' . $context . '.php'),
        $configReaderFactory->createReader('PREFIX', ['type' => 'env']),
        $configReaderFactory->createReader($confDir . '/override.php'),
    ]
);
$config = $configLoader->load();
```

Basic usage cached
------------------

[](#basic-usage-cached)

```
$context = 'production';
$confDir = '/path/to/conf';
$cacheDir = '/path/to/cache';
$cacheIdentifier = md5($context . filemtime('/path/to/.env'));
$configReaderFactory = new \Helhum\ConfigLoader\ConfigurationReaderFactory($confDir);
$configLoader = new \Helhum\ConfigLoader\CachedConfigurationLoader(
    $cacheDir,
    $cacheIdentifier,
    function() use ($confDir, $context, $configReaderFactory) {
        return new \Helhum\ConfigLoader\ConfigurationLoader(
            [
                $configReaderFactory->createReader($confDir . '/default.php'),
                $configReaderFactory->createReader($confDir . '/' . $context . '.php'),
                $configReaderFactory->createReader('PREFIX', ['type' => 'env']),
                $configReaderFactory->createReader($confDir . '/override.php'),
            ]
        );
    }
);
$config = $configLoader->load();
```

Using processors
----------------

[](#using-processors)

It is possible to add one or more processors to the config loader.

```
$context = 'production';
$confDir = '/path/to/conf';
$configReaderFactory = new \Helhum\ConfigLoader\ConfigurationReaderFactory($confDir);
$configLoader = new \Helhum\ConfigLoader\ConfigurationLoader(
    [
        $configReaderFactory->createReader($confDir . '/config.php'),
    ],
    [
        new \Helhum\ConfigLoader\Processor\PlaceholderValue(),
    ]
);
$config = $configLoader->load();
```

Advanced usage
--------------

[](#advanced-usage)

Instead of hard coding which configuration sources should be included, it is possible to include multiple sources from within one configuration file.

```
$context = 'production';
$confDir = '/path/to/conf';
$configReaderFactory = new \Helhum\ConfigLoader\ConfigurationReaderFactory($confDir);
$configLoader = new \Helhum\ConfigLoader\ConfigurationLoader(
    [
        $configReaderFactory->createRootReader($confDir . '/config.yaml'),
    ]
);
$config = $configLoader->load();
```

The configuration file can then include an `import` section:

```
imports:
    - { resource: 'config.*.yml', type: glob }
    - { resource: 'env.yml' }
```

Feedback
--------

[](#feedback)

Any feedback is appreciated. Please write bug reports, feature request, create pull requests, or just drop me a "thank you" via [Twitter](https://twitter.com/helhum)or spread the word.

Thank you!

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity56

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.8% 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 ~149 days

Recently: every ~506 days

Total

22

Last Release

564d ago

PHP version history (6 changes)0.4.0PHP &gt;=7.0.0 &lt;7.2.0

v0.6.0PHP &gt;=7.0.0 &lt;7.3.0

v0.12.0PHP &gt;=7.0 &lt;7.4

v0.12.2PHP ^7

v0.12.3PHP &gt;7.0

v0.12.4PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/904370?v=4)[Helmut Hummel](/maintainers/helhum)[@helhum](https://github.com/helhum)

---

Top Contributors

[![helhum](https://avatars.githubusercontent.com/u/904370?v=4)](https://github.com/helhum "helhum (89 commits)")[![gilbertsoft](https://avatars.githubusercontent.com/u/25326036?v=4)](https://github.com/gilbertsoft "gilbertsoft (3 commits)")[![smichaelsen](https://avatars.githubusercontent.com/u/912435?v=4)](https://github.com/smichaelsen "smichaelsen (2 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (1 commits)")[![bmack](https://avatars.githubusercontent.com/u/165630?v=4)](https://github.com/bmack "bmack (1 commits)")[![infabo](https://avatars.githubusercontent.com/u/3999104?v=4)](https://github.com/infabo "infabo (1 commits)")[![mbrodala](https://avatars.githubusercontent.com/u/5037116?v=4)](https://github.com/mbrodala "mbrodala (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/helhum-config-loader/health.svg)

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

###  Alternatives

[advmaker/carbon-period

Extension of nesbot/carbon plugin, to work with date period

10116.3k](/packages/advmaker-carbon-period)

PHPackages © 2026

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