laminas-config-aggregator

A lightweight PHP library for collecting and merging application configuration from multiple providers and formats.

Library
Composer
v1.20.0
41stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
61/100Good
Development Activity76
Maintenance68
Community28
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture74
Code Quality78
Innovation55
Learning Curve80

laminas-config-aggregator is a small, focused library for assembling a single, merged configuration array from many sources — PHP files returning arrays, YAML/JSON/XML/INI files (via laminas-config), or arbitrary config-provider classes. Providers are supplied in order to a ConfigAggregator, and later entries take precedence when keys collide, giving applications a predictable, override-friendly configuration pipeline.

It’s designed to be framework-agnostic and lightweight enough to sit at the bootstrap layer of any PHP application, with built-in support for caching the merged result to a file so production requests skip the aggregation step entirely. It underpins configuration loading in Mezzio and other Laminas-ecosystem projects but has no hard dependency on any specific framework.

What You Get

  • A ConfigAggregator class that merges configuration from an ordered list of providers, later entries winning on key conflicts
  • A PhpFileProvider for glob-based loading of PHP files that return config arrays
  • A LaminasConfigProvider for loading YAML, JSON, XML, or INI files via laminas-config
  • Built-in merged-config caching to a PHP file for fast, cache-hit bootstraps in production
  • A ConfigAggregatorInterface/provider pattern that makes it easy to write custom sources (env vars, remote config, etc.)

Common Use Cases

  • Bootstrapping application-wide configuration from a directory of environment-specific PHP config files
  • Layering local development overrides on top of shared, versioned base configuration
  • Combining config formats (YAML for humans, PHP for computed values) into one aggregated array
  • Powering the config layer of a Mezzio or other Laminas-component-based application

Under The Hood

Architecture - The library centers on ConfigAggregator, which accepts an ordered array of provider callables/objects and a merge strategy, iterating each provider to build and merge configuration arrays with ArrayUtils::merge. Providers like PhpFileProvider and LaminasConfigProvider implement a simple glob-and-load pattern, decoupling the source of config (files, formats, or custom logic) from the aggregation mechanism itself, which is what lets applications mix PHP arrays with YAML/JSON/XML/INI files transparently.

Tech Stack - Pure PHP with no mandatory runtime dependencies beyond PHP itself; laminas/laminas-config is an optional dependency pulled in only when using LaminasConfigProvider for non-PHP formats. It’s distributed via Composer under the Laminas\ConfigAggregator namespace with PSR-4 autoloading, and CI runs via GitHub Actions across supported PHP versions.

Code Quality - As part of the broader Laminas project (589 commits, 23 contributors, 20 tagged releases), the codebase follows the Laminas coding standard, includes a PHPUnit test suite, and uses static analysis tooling common across Laminas components (PHPStan/Psalm-style checks in CI). The scope is intentionally narrow, which keeps the logic easy to reason about and test exhaustively.

API Design - The API is minimal by design: construct a ConfigAggregator with an array of providers and call getMergedConfig(). Providers are simple, single-purpose classes or closures, so adding a new configuration source (e.g., environment variables) requires implementing one small callable rather than extending a large class hierarchy — a deliberately low-boilerplate design.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search