Category : configuration

I have following configuration: $treeBuilder = new TreeBuilder(‘rest_api’); $treeBuilder->getRootNode() ->addDefaultsIfNotSet() ->children() ->arrayNode(‘exceptions’) ->defaultValue([]) ->arrayPrototype() ->scalarPrototype() ->end() ->end() ->end() ->end(); And following 2 files in 2 different bundles: rest_api: exceptions: 404: – UserNotFoundException 400: – InvalidCredentailsException rest_api: exceptions: 404: – NotFoundHttpException 400: – SomeRandomException – OtherRandomException I wanted the result to look like this: ^ array:1 ..

Read more

In former versions of Symfony, I could set my configuration like this in parameters.yml: app: group1: param1: ‘myvalue’ And read its value with $this->getParameter(‘app.group1.param1′). In Symfony 4.4 this format seems to be not working, and I’m forced to do this in my services.yml file: app.group1.param1 The docs only refer to this format and doing otherwise ..

Read more

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() ->end ->end() The employee should be conditionally required based on type How do I approach ..

Read more

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 ..

Read more

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: uri_prefix: /images/properties upload_destination: ‘%kernel.project_dir%/public/images/properties’ But it creates an error: (2/2) FileLoaderLoadException There is no extension ..

Read more