Last active
February 14, 2017 11:55
-
-
Save christeredvartsen/5b576116f69ff3ad82bfb8a2de395a32 to your computer and use it in GitHub Desktop.
Build a free-form config definition with default values with Symfony\Component\Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $builder is an instance of Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition | |
$builder | |
->children() | |
->arrayNode('params') | |
->info('Arbitrary key => value configuration') | |
->useAttributeAsKey('name') | |
->prototype('scalar')->end() | |
->end() | |
->end(); | |
/* When dumped as YAML I would like my config to look something like this: | |
* | |
* params: | |
* key1: value1 | |
* key2: value2 | |
* | |
* Then a user can add the following config: | |
* | |
* params: | |
* key2: some value | |
* key3: value3 | |
* | |
* Which would result in the following configuration: | |
* | |
* params: | |
* key1: value1 | |
* key2: some value | |
* key3: value3 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment