Reputation: 2277
I have a service which have definition something like this
puff_service:
driver: mysql
I know how to load the configuration but in this case I would like to write this configuration in config.yml automatically when people install the bundle for the first time. Is there anyway to do this.
Upvotes: 0
Views: 363
Reputation: 29912
You need to enhance your bundle with a bundle extension in which is possible to specify default values without forcing final user to write them in config.yml
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('puff_service');
$rootNode
->children()
->scalarNode('driver')
->default('mysql')
->end()
->end()
;
return $treeBuilder;
}
}
This way, who include your bundle will have as default driver mysql; if a change is needed, they can specify it directly in config.yml
Upvotes: 2