How to add an array with values in Symfony2 configuration? How to add an array with values in Symfony2 configuration? symfony symfony

How to add an array with values in Symfony2 configuration?


If you want to achieve a node like this, just do:

$rootNode    ->children()        ->arrayNode('columns')            ->prototype('scalar')            ->end()        ->end()    ->end();


I think you're missing that YaML is not a markup language, it's not even a langauge as such (It's a data serialization standard), so it doesn't know of any language constructs, like arrays. Its main "tool" to express grouping and relations between bits of data is whitespace, colons and dashes.
From the symfony documentation page of the YaML format:

my_bundle:    columns:         - col1        - col2

As I gather from this section:

A YAML file is rarely used to describe a simple scalar. Most of the time, it describes a collection. A collection can be a sequence or a mapping of elements. Both sequences and mappings are converted to PHP arrays.

Sequences use a dash followed by a space:

- PHP

- Perl

- Python

The previous YAML file is equivalent to the following PHP code:

array('PHP', 'Perl', 'Python');