Don’t like the idea of manually setting certain values in your Symfony YAML configuration files? Or maybe, like in my case, you want the value of one setting to be set based on the value of a previous one, maybe a calculation of other values for instance. It may not be obvious at first but you can include PHP blocks in your config files. You just need to be a little careful about the line endings in order for it to work properly. If you take a look at your apps/application/config/settings.yml there’s already an example in there in how to achieve this:
dev:
.settings:
error_reporting: <?php echo ((E_ALL | E_STRICT) ^ E_NOTICE)."\n" ?>
Here’s a (silly) example of what you may want to put in your app.yml:
<?php $i = 10; ?>
all:
numbers:
option1: <?php echo ($i++) . "\n" ?>
option2: <?php echo ($i++) . "\n" ?>
default: <?php echo $i . "\n" ?>
Just note “\n” at the end of the line as this is important. Without it the newline character won’t be added and the resulting YAML will be malformed. Also be really careful not to put any spaces or anything in front of a PHP block that doesn’t output anything, such as the first line in that example since that will also be malformed YAML. Just always remember to think of what the output will look like and that it must be valid YAML.
Note: I’m using Symfony 1.4 and haven’t verified this in other versions.