doushang4274
2015-02-19 11:18
浏览 44
已采纳

如何从Symfony2中的包中覆盖全局Monolog配置

I would like to override the global config.yml Monolog configuration from inside of my bundle. Hovewer, when I try to write something like:

monolog:
    # some new configuration params

I get this error:

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
There is no extension able to load the configuration for "monolog"

Is there a way to modify the configuration without resorting to adding compiler passes?

图片转代码服务由CSDN问答提供 功能建议

我想从我的包里面覆盖全局 config.yml Monolog配置 。 Hovewer,当我尝试编写类似的东西时:

  monolog:
#some some configuration params 
   
 
 

我收到此错误:

  [Symfony \ Component \ DependencyInjection \ Exception \ InvalidArgumentException] 
没有可以加载配置的扩展名 for“monolog”
   
 
 

有没有办法修改配置而不需要添加编译器传递?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douri4459 2016-06-07 08:39
    已采纳

    I know maybe I'm late, but I have found a solution for this because I wanted to do the same.

    In you bundle extension load method, you should register the MonologExtension, then you can load monolog configuration in your bundle config files:

    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');
    }
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题