Category: configuration

Symfony semantic configuration – require different fields based on type

Let’s assume the following example config: people: alice: type: employee nick: SuperAlice department: accounting bob: type: guest nick: HappyBob The semantic config will look similar to: ->arrayNode(‘people’) ->arrayPrototype() ->children() ->scalarNode(‘type’)->isRequired()->end() ->scalarNode(‘nick’)->defaultNull()->end() ->scalarNode(‘department’)->end() // should be req. for type=employee only ->end()…

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()…

VichUploaderBundle with symfony 4: no extension able to load the configuration for "mappings"

I’m trying to use VichUploaderBundle to handle a file upload. I work with symfony 4. I have a problem in the first step (Step 1: configure an upload mapping). in the app/config/config.yml file I have: vich_uploader: db_driver: orm mappings: property_image:…