我想从我的包内部覆盖全局config.yml
Monolog配置。 Hovewer,当我尝试写类似的东西时:
monolog:
# some new configuration params
我收到此错误:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
There is no extension able to load the configuration for "monolog"
有没有办法修改配置而不需要添加编译器传递?
答案 0 :(得分:2)
我知道也许我迟到了,但我找到了解决办法,因为我想做同样的事。
在捆绑扩展加载方法中,您应该注册MonologExtension,然后您可以在捆绑配置文件中加载monolog配置:
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
// Register extension to load monolog configuration in bundle.
$container->registerExtension(new MonologExtension());
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('config_' . $container->getParameter('kernel.environment') . '.yml');
}