Symfony2 arrays as parameters in xml dependeny injection

Symfony documentation recommends to use XML for dependency injection configuration. I like the yml format because its simple and intuitive, but the main benefit of XML is the possibility for better validation and editing help.
So today we tried to port some configuration from yaml to xml.
Our yaml file contained an array parameter:

        en: [en, de]
        de: [de, en]

To make this work in XML, you need to nest parameter tags and use the type="collection" attribute.

    <parameter key="symfony_cmf_multilang_content.lang_preference" type="collection">
        <parameter key="en" type="collection">
        <parameter key="de" type="collection">

If you forget the type="collection" attribute, your parameter will contain whitespace from between the xml tags, but no content. You will probably just get some random error somewhere about things not being an array. (That is, if you do not validate your configuration. If you do, you will get errors in the validation so at least you will be closer to the place of the problem.)


symfony doc

just a short notice: this information is now part of the official symfony doc too:


you spoke of validation configuration xml, how is that done? or how did you do it?


configuration validation

i do not validate with an xml schema myself, but maybe this cookbook entry helps you: