How can I use a deep default configuration in symfony

I am trying to create a bundle that wont require a config file, but default values do not work.

Here is the code:

    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder('acme_newsletter');

        $treeBuilder->getRootNode()
            ->children()
                ->arrayNode('security')
                    ->children()
                        ->scalarNode('foo_key')->defaultValue('%env(FOO_KEY)%')->end()
                        ->scalarNode('bar_key')->defaultValue('%env(BAR_KEY)%')->end()
                        ->scalarNode('baz_key')->defaultValue('%env(BAZ_KEY)%')->end()
                    ->end()
                ->end()
            ->end();

        return $treeBuilder;
    }

Now when I use this file Symfony wont use the default values unless I create at least following config file:

acme_newsletter:
   security:

Is there a way to use default values without requiring any files to be created?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *