This package supplies a zend-config-aggregator post processor that consumes the Symfony DependencyInjection ParameterBag in order to allow users to define parameters to re-use within their configuration.

As an example, one could define an API key, cache path, or other common filesystem location once as a parameter, and then refer to that parameter multiple times within the configuration, in order to simplify updates to the value.

Parameters are referenced within configuration using %name% notation. Parameters may be defined as nested associative arrays as well; in such cases, a . character references an additional layer of hierarchy to dereference: refers to the paramter found at 'foo' => [ 'bar' => 'value' ].

Starting in version 1.1.0, you can use parameters which reference other parameters as well.

If you wish to use a literal %name% within your configuration, you must double-escape the percentage signs: %%name%%. Failure to do so will result in an exception when post-processing the configuration.

As a self-contained example:

use Zend\ConfigAggregator\ArrayProvider;
use Zend\ConfigAggregator\ConfigAggregator;
use Zend\ConfigAggregatorParameters\ParameterPostProcessor;

$aggregator = new ConfigAggregator(
        new ArrayProvider([
            'parameter_usage' => '%foo%',
            'parameter_name' => '%%foo%%',
            'recursive_parameter_usage' => '%bar.baz%',
            'parameterized_parameter_usage' => '%bar.quux%',
        new ParameterPostProcessor([
            'foo' => 'bar',
            'bar' => [
                'baz' => 'qoo',
                'quux' => '%foo%', // Since 1.1.0


The result of the above will be:

array(5) {
  'parameter_usage' =>
  string(3) "bar"
  'parameter_name' =>
  string(5) "%foo%"
  'recursive_parameter_usage' =>
  string(3) "qoo"
  'parameterized_parameter_usage' =>
  string(3) "bar"
  'parameters' =>
  array(4) {
    'foo' =>
    string(3) "bar"
    'bar' =>
    array(2) {
      'baz' =>
      string(3) "qoo"
      'quux' =>
      string(3) "bar"
    'bar.baz' =>
    string(3) "qoo"
    'bar.quux' =>
    string(3) "bar"

Found a mistake or want to contribute to the documentation? Edit this page on GitHub!