PHPackages                             mtymek/expressive-config-manager - 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. mtymek/expressive-config-manager

Abandoned → [zendframework/zend-config-aggregator](/?search=zendframework%2Fzend-config-aggregator)Library[Utility &amp; Helpers](/categories/utility)

mtymek/expressive-config-manager
================================

Lightweight library for merging and caching application config

0.4.0(10y ago)3076.4k↓29.3%42BSD 3-ClausePHPPHP ^5.5 || ^7.0

Since Dec 3Pushed 9y ago8 watchersCompare

[ Source](https://github.com/mtymek/expressive-config-manager)[ Packagist](https://packagist.org/packages/mtymek/expressive-config-manager)[ RSS](/packages/mtymek-expressive-config-manager/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (4)Versions (15)Used By (2)

Expressive Configuration Manager
================================

[](#expressive-configuration-manager)

**Deprecated!** This library was merged into Zend Framework organization as [zend-config-aggregator](https://github.com/zendframework/zend-config-aggregator) - please use it instead.

---

Lightweight library for collecting and merging configuration from different sources.

It is designed for [zend-expressive](https://github.com/zendframework/zend-expressive)applications, but it can work with any PHP project.

Usage
-----

[](#usage)

### Config files

[](#config-files)

At the basic level, ConfigManager can be used to merge PHP-based configuration files:

```
use Zend\Expressive\ConfigManager\ConfigManager;
use Zend\Expressive\ConfigManager\PhpFileProvider;

$configManager = new ConfigManager(
    [
        new PhpFileProvider('*.global.php'),
    ]
);

var_dump($configManager->getMergedConfig());
```

Each file should return plain PHP array:

```
// db.global.php
return [
    'db' => [
        'dsn' => 'mysql:...',
    ],
];

// cache.global.php
return [
    'cache_storage' => 'redis',
    'redis' => [ ... ],
];
```

Result:

```
array(3) {
  'db' =>
  array(1) {
    'dsn' =>
    string(9) "mysql:..."
  }
  'cache_storage' =>
  string(5) "redis"
  'redis' =>
  array(0) {
     ...
  }
}
```

Configuration is merged in the same order as it is passed, with later entries having precedence.

### Config providers

[](#config-providers)

ConfigManager works by aggregating "Config Providers" passed when creating object. Each provider should be a callable, returning configuration array (or generator) to be merged.

```
$configManager = new ConfigManager(
    [
        function () { return ['foo' => 'bar']; },
        new PhpFileProvider('*.global.php'),
    ]
);
var_dump($configManager->getMergedConfig());
```

If provider is a class name, it is automatically instantiated. This can be used to mimic ZF2 module system - you can specify list of config classes from different packages, and aggregated configuration will be available to your application. Or, as a library owner you can distribute config class with default values.

Example:

```
class ApplicationConfig
{
    public function __invoke()
    {
        return ['foo' => 'bar'];
    }
}

$configManager = new ConfigManager(
    [
        ApplicationConfig::class,
        new PhpFileProvider('*.global.php'),
    ]
);
var_dump($configManager->getMergedConfig());
```

Output from both examples will be the same:

```
array(4) {
  'foo' =>
  string(3) "bar"
  'db' =>
  array(1) {
    'dsn' =>
    string(9) "mysql:..."
  }
  'cache_storage' =>
  string(5) "redis"
  'redis' =>
  array(0) {
  }
}
```

### Caching

[](#caching)

In order to enable configuration cache, pass cache file name as a second parameter to `ConfigManager` constructor:

```
$configManager = new ConfigManager(
    [
        function () { return [ConfigManager::ENABLE_CACHE => true]; },
        new PhpFileProvider('*.global.php'),
    ],
    'data/config-cache.php'
);
```

When cache file is specified, you will also need to add `config_cache_enabled` key to the config, and set it to `TRUE` (use `ConfigManager::ENABLE_CACHE` constant for convenience). This allows to enable cache during deployment by simply putting extra `*.local.php` file in config directory:

```
return [
    ConfigManager::ENABLE_CACHE` => true,
];
```

When caching is enabled, `ConfigManager` does not iterate config providers. Because of that it is very fast, but after it is enabled you cannot do any changes to configuration without clearing the cache. **Caching should be used only in production environment**, and your deployment process should clear the cache.

### Generators

[](#generators)

Config providers can be written as generators. This way single callable can provide multiple configurations:

```
$configManager = new ConfigManager(
    [
        function () {
            foreach (Glob::glob('data/*.global.php', Glob::GLOB_BRACE) as $file) {
                yield include $file;
            }
        }
    ]
);
var_dump($configManager->getMergedConfig());
```

`PhpFileProvider` is implemented using generators.

Available config providers
--------------------------

[](#available-config-providers)

### PhpFileProvider

[](#phpfileprovider)

Loads configuration from PHP files returning arrays, like this one:

```
return [
    'db' => [
        'dsn' => 'mysql:...',
    ],
];
```

Wildcards are supported:

```
$configManager = new ConfigManager(
    [
        new PhpFileProvider('config/*.global.php'),
    ]
);
```

Example above will merge all matching files from `config` directory - if you have files like `app.global.php`, `database.global.php`, they will be loaded using this few lines of code.

Internally, `ZendStdlib\Glob` is used for resolving wildcards, meaning that you can use more complex patterns (for instance: `'config/autoload/{{,*.}global,{,*.}local}.php'`), that will work even on Windows platform.

### ZendConfigProvider

[](#zendconfigprovider)

Sometimes using plain PHP files may be not enough - you may want to build your configuration from multiple files of different formats: INI, YAML, or XML. For this purpose you can leverage `ZendConfigProvider`:

```
$configManager = new ConfigManager(
    [
        new ZendConfigProvider('*.global.json'),
        new ZendConfigProvider('database.local.ini'),
    ]
);
```

`ZendConfigProvider` accepts wildcards and autodetects config type based on file extension.

ZendConfigProvider requires two packages to be installed: `zendframework/zend-config` and `zendframework/zend-servicemanager`. Some config readers (JSON, YAML) may need additional dependencies - please refer to [Zend Config Manual](http://framework.zend.com/manual/current/en/index.html#zend-config)for more details.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.9% 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 ~24 days

Total

5

Last Release

3761d ago

PHP version history (2 changes)0.3.0PHP ^5.5 || 7.0

0.3.1PHP ^5.5 || ^7.0

### Community

Maintainers

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

---

Top Contributors

[![mtymek](https://avatars.githubusercontent.com/u/777893?v=4)](https://github.com/mtymek "mtymek (47 commits)")[![bakura10](https://avatars.githubusercontent.com/u/1198915?v=4)](https://github.com/bakura10 "bakura10 (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mtymek-expressive-config-manager/health.svg)

```
[![Health](https://phpackages.com/badges/mtymek-expressive-config-manager/health.svg)](https://phpackages.com/packages/mtymek-expressive-config-manager)
```

###  Alternatives

[prism-php/relay

A Prism tool for interacting with MCP servers

15074.0k5](/packages/prism-php-relay)[spatie/laravel-long-running-tasks

Handle long running tasks in a Laravel app

389.2k](/packages/spatie-laravel-long-running-tasks)

PHPackages © 2026

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