how do i load a custom config file in a bundleless application using treebuilder?

Seems like I saw a similar question a few months ago but can’t find it. The src/Kernel class acts as a AppBundle class and allows you to do things like register extensions.

# src/Kernel.php
class Kernel extends BaseKernel
    use MicroKernelTrait;

    protected function prepareContainer(ContainerBuilder $container)
        $container->registerExtension(new TestExtension());
# src/TestExtension.php
class TestExtension extends Extension
    public function load(array $configs, ContainerBuilder $container)
        // TODO: Implement load() method.

As far as processing a tree builder without an extension, I don’t know if that is possible. The config stuff is already complicated enough so I would not go there myself.

Bit off-topic, I could not find an actual documented case of using prepareContainer in Kernel. The source code makes it clear that the approach shown above will work.

Most of the time app specific configurations are just done in the config directory. The main point of the bundle configuration system is to allow the app to override default bundle configurations. I’m not really seeing the point of an app level extension. What would override it? Maybe some sort of sophisticated database driven tree builder? Seems unlikely.

This could be a case of just because you can do something does not mean you should.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top