Silex (Pimple) provider for configuration management

2.0 2017-03-17 16:58 UTC


A configuration provider for the Silex micro-framework.


The configuration loader uses the concept of configuration files (containing the configuration skeleton) and parameter files (variables that customize the configuration).

Moving some configuration values outside of the config skeleton allows config files to be commited to version control and remain identical everywhere, while leaving certain "parameters" up for customization.

Parameter files can be provided to the library as file paths or as PHP arrays of values. The latter is useful whenever you want to grab some environment variables.

Example configuration:

        "key": "value",
        "something": "%something%",
        "websites": {
                "first": "%main_website%",
                "second": "%another_website%"

        "something": "value for something",
        "main_website": "",
        "another_website": ""


    $app->register(new \Devture\SilexProvider\Config\ServicesProvider());

    $configFiles = array('/path/to/config.json');

//Each is either a path to a parameter file (JSON) or an array of parameters (key => value dictionary).
    $parameterFiles = array(
    array('something' => 'overriden value for something'),

    $app['config'] = $app['devture_config.loader']->load($configFiles, $parameterFiles);


$app['config'] = array(
        'key' => 'value',
        'something' => 'overriden value for something',
        'websites' => array(
                'first' => '',
                'second' => '',


  • Only JSON config files an inline arrays are supported (intentional)
  • Partial parameter replacements are not supported ("storage_path": "%base_path%/storage") - may be implemented later