laminas/laminas-config-aggregator
Aggregate and merge configuration from multiple providers in Laminas/Mezzio apps. Supports ordered loading, caching, PHP/array and glob-based config files, and environment-specific overrides for fast, predictable configuration builds.
config/global.php + config/prod.php).vendor/module-name/config/module.php).Adopt When:
config.php, database.php, services.php) and merging them manually is error-prone.Look Elsewhere If:
config.php file with no overrides).ParameterBag, Laravel’s config/ directory) that already meets your needs."This package lets us centralize and automate configuration management, reducing errors from manual merges and enabling faster, more reliable deployments. By standardizing how we handle configs—across environments, modules, and formats—we’ll cut down on ‘works on my machine’ issues and make it easier to onboard new developers. It’s a lightweight, open-source solution that aligns with our modular architecture, saving dev time while improving scalability. Think of it as ‘Git for configurations’—version control for your app’s settings."
Key Outcomes:
"laminas-config-aggregator gives us a flexible, performant way to merge and process configs from multiple sources (PHP, JSON, YAML, etc.) with support for caching and runtime transformations. Here’s how we’d use it:
Replace Manual Merges: Instead of concatenating config.php + local.php + prod.php by hand, we’d define providers in code:
$aggregator = new ConfigAggregator([
new PhpFileProvider('config/global.php'),
new PhpFileProvider('config/{env}.php'), // e.g., config/prod.php
]);
Later configs override earlier ones, and we can add/remove files without rewriting the app.
Support Multiple Formats: Load config.json, database.yml, or services.ini in the same pipeline using LaminasConfigProvider.
Dynamic Processing:
%env.DB_URL% placeholders or validate schemas).Performance: Cache merged configs in production to avoid re-parsing files on every request.
Extensibility: Write custom providers (e.g., load configs from a database or API) or reuse existing ones from the Laminas ecosystem.
This is especially useful for our [modular roadmap] and [microservices initiative], where we need to aggregate configs from multiple sources cleanly. It’s also a drop-in replacement for our current ad-hoc merging logic, so migration risk is low."
Tech Benefits:
require chains).How can I help you explore Laravel packages today?