Symfony2 - Defining boolean parameter in parameters.ini
Default Symfony2 import parameters in YAML format, so one of first line should be:
imports:
- { resource: parameters.yml }
And in parameters.yml use:
aParameter: true
I dont use INI files, so i dont know how it works.
Symfony 2 uses parse_ini_file() function and it does not seem to return the right type for boolean value.
<?php
file_put_contents('test.ini', "test1=on\ntest2=true\ntest3=1");
var_dump(parse_ini_file('test.ini'));
will output
array(3) {
'test1' => string(1) "1"
'test2' => string(1) "1"
'test3' => string(1) "1"
}
You might want to implement your own ini
parser taking Symfony\Component\DependencyInjection\Loader\IniFileLoader
as an example.
Example of lexer that supports booleans can be found in comments at php doc for parse_ini_file()
An alternative would be to use the yaml format for your configuration file.
Looks like there is no way to achieve it. See this issue. Simplest way is to replace your parameters.ini with parameters.yml
For example, parameters.yml.dist from symfony-standard