L
L
Leonid Korsakov2015-03-23 17:23:35
symfony
Leonid Korsakov, 2015-03-23 17:23:35

How to merge several yaml files into one?

There are several layers of configuration files in yaml format.
- server config - default
config
- default server dev
The last one should overwrite the settings of the previous ones. Not all, but only those that are described in it. Which are not described are taken from the files above. To parse yaml files, a component from symfony2 is used. But the project itself does not use this framework
. Yaml allows you to use links

my:
    setval: &id001
        simple text
fortest:
    testval: *id001

The question is how to combine these files into one so that such links work from different files. That is, for example, the link is declared in the first file, but is used in the third. It is necessary that the substitution work during parsing. It's not possible to simply merge files, because sections like my and fortest are repeated in files, and when parsing such a connected file, the section from the last file gets into the result.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Alekhin, 2015-03-24
@Vit228

did you try to turn yml files into php arrays and then merge the arrays?

S
shagguboy, 2015-10-15
@shagguboy

imports:
- { resource: parameters.yml }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question