I have this config in config.yml file in my Symfony 3.5 project:
my_config:
token: mHSHlSHl-QqSHlX-SHlQqShzO2ibzGnsNk-Q
username: test
development:
developers_id: [130]
maintenance:
enable: true
text: "text of text"
I have a bundle to parse this config in my configuration.php file. In the bundle dependency injection I have this code:
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('my_bundle');
$rootNode->children()
->scalarNode("username")
->end()
->scalarNode("token")
->isRequired()
->end()
->arrayNode('development')
->children()
->booleanNode('send_log')
->defaultFalse()
->end()
->arrayNode('developers_id')
->prototype('scalar')
->end()
->arrayNode('maintenance')
->children()
->booleanNode('enable')
->defaultFalse()
->end()
->scalarNode('text')
->defaultValue('default text')
->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
When I run this code I get this error:
Attempted to call an undefined method named "arrayNode" of class "Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition".
What should I do?
cache:clear [--env=...] [--no-debug]), if that doesn't help: Break up the code right before the line that throws the error and dump$rootNodeat that point to see it's type.