Symfony 5 reusable bundle config TreeBuilder: invalide type for path

  bundle, symfony4, symfony5

I’m trying to create a reusable bundle and i get Invalid type for path "bayard_directus.authentication.email". Expected "array", but got "string"
the TreeBuilder looks like this:

$treeBuilder = new TreeBuilder('bayard_directus');


       $treeBuilder->getRootNode()
           ->children()

               ->arrayNode('authentication')
                   ->arrayPrototype()
                   ->children()
                       ->scalarNode('email')->defaultValue("%env(PEE_CMS_API_MAIL)%")->end()
                       ->scalarNode('password')->defaultValue("%env(PEE_CMS_API_PWD)%")->end()
                       ->scalarNode('cache')->defaultValue('PSR-6')->end()
                   ->end()
           ->end()
               ->end()
           ->scalarNode('base_url')->defaultValue("%env(PEE_CMS_API_URL)%")->end()

           ->end()

           ->end()

     ;

       return $treeBuilder;

the YML file :

bayard_directus:
  authentication:
    email: '%env(PEE_CMS_API_MAIL)%'
    password: '%env(PEE_CMS_API_PWD)%'
    cache: "PSR-6"

  base_url: '%env(PEE_CMS_API_URL)%'

Source: Symfony4 Questions

LEAVE A COMMENT