I want to get PHP Array from parameters.yml in Symfony, example :
parameters:
keek.color:
blue:
- color1
- color2
red:
- color3
- color4
Is it possible?
I want to get PHP Array from parameters.yml in Symfony, example :
parameters:
keek.color:
blue:
- color1
- color2
red:
- color3
- color4
Is it possible?
Yes, you can retrieve with the method getParameter on the container instance, as example:
$container->getParameter('keek.color');
In a controller with the shortcut:
$this->getParameter('keek.color');
And will return an array:
array(2) {
'blue' =>
array(2) {
[0] =>
string(6) "color1"
[1] =>
string(6) "color2"
}
'red' =>
array(2) {
[0] =>
string(6) "color3"
[1] =>
string(6) "color4"
}
}