Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spantaleev/silex-provider-config
A configuration provider for Silex
https://github.com/spantaleev/silex-provider-config
Last synced: 3 months ago
JSON representation
A configuration provider for Silex
- Host: GitHub
- URL: https://github.com/spantaleev/silex-provider-config
- Owner: spantaleev
- License: bsd-3-clause
- Created: 2013-02-23T12:19:04.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-03-17T16:58:45.000Z (almost 8 years ago)
- Last Synced: 2024-09-13T13:35:06.408Z (4 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Silex Config Provider
=====================A configuration provider for the `Silex `_ micro-framework.
Usage
-----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::
//config.json
{
"key": "value",
"something": "%something%",
"websites": {
"first": "%main_website%",
"second": "%another_website%"
}
}//parameters.json
{
"something": "value for something",
"main_website": "http://devture.com/",
"another_website": "http://github.com/spantaleev"
}Usage::
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(
'/path/to/parameters.json',
array('something' => 'overriden value for something'),
);$app['config'] = $app['devture_config.loader']->load($configFiles, $parameterFiles);
Result::
$app['config'] = array(
'key' => 'value',
'something' => 'overriden value for something',
'websites' => array(
'first' => 'http://devture.com/',
'second' => 'http://github.com/spantaleev',
)
);Limitations
------------* 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