Example below shows you how parameters can be set in parameters.yml file.


Parameters.yml


# app/config/parameters.yml
parameters:
string: one
array_1: one two
array_2: [one two]
array_3: [one: two]
array_4: {one two}
array_5: {one: two}
array_6:
name: one
year: two
array_7:
- one
- two
array_8:
dim_1:
- one
- two
dim_2:
- one
- two

Test


Assuming that we're printing parameters in a controller.


echo '<pre>';                                                    

echo $this->container->getParameter('string'); echo PHP_EOL;
print_r($this->container->getParameter('array_1')); echo PHP_EOL;
print_r($this->container->getParameter('array_2')); echo PHP_EOL;
print_r($this->container->getParameter('array_3')); echo PHP_EOL;
print_r($this->container->getParameter('array_4')); echo PHP_EOL;
print_r($this->container->getParameter('array_5')); echo PHP_EOL;
print_r($this->container->getParameter('array_6')); echo PHP_EOL;
print_r($this->container->getParameter('array_7')); echo PHP_EOL;
print_r($this->container->getParameter('array_8')); echo PHP_EOL;

exit;

Output


one

one two

Array
(
[0] => one two
)

Array
(
[0] => Array
(
[one] => two
)
)

Array
(
[one] => two
)

Array
(
[one] => two
)

Array
(
[name] => one
[year] => two
)

Array
(
[0] => one
[1] => two
)

Array
(
[dim_1] => Array
(
[0] => one
[1] => two
)

[dim_2] => Array
(
[0] => one
[1] => two
)
)