Reputation: 2462
I'm trying to define some custom config values for my Symfony Flex application (which will be filled with .env values), but all the docs assume I'm using a bundle, like this one: https://symfony.com/doc/current/bundles/extension.html
I have a custom namespace, something like 'Foo\Bar', so I though the Extension class should be called src\DependencyInjection\FooBarExtension.php
, but that doesn't work.
Does anyone know how I can load my custom config?
Edit: the following solution worked:
Put config file foo.yaml
in config/packages
Put FooExtension.php
in src/DependencyInjection
Add following code to Kernel.php
public function build(ContainerBuilder $container)
{
$container->registerExtension(new FooExtension());
parent::build($container);
}
Upvotes: 0
Views: 492
Reputation: 3319
In Symfony 4.1, you should be able to register a new extension in your AppKernel
by overriding the build()
method. There, you can register your extensions which in turn enable you to parse your own configuration files.
Upvotes: 2