【问题标题】:SonataMediaBundle You have requested a non-existent parameter "doctrine.connections" errorSonataMediaBundle 您请求了一个不存在的参数“doctrine.connections”错误
【发布时间】:2012-09-29 10:33:39
【问题描述】:

我在我的 Symfony 2.1.2 项目上设置了 SonataAdminBundle,它可以正常工作。现在我正在尝试设置 SonataMediaBundle,但出现此错误:

==> php app/console sonata:easy-extends:generate SonataMediaBundle



  [Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]  
  You have requested a non-existent parameter "doctrine.connections".         

我按照文档说明将配置参数复制到 config.yml。你可以在那里看到它:http://pastebin.com/wys11net

任何帮助或线索?

提前致谢

【问题讨论】:

    标签: symfony symfony-2.1 sonata-admin


    【解决方案1】:

    看起来您缺少 Doctrine > DBAL 节点中的 Connections 节点,以及默认连接的规范(如果是这样的话,在多个连接中)。 right 模板的示例如下:

    doctrine:
        dbal:
            default_connection:   default
            connections:
                default:
                    driver:   %database_driver%
                    host:     %database_host%
                    port:     %database_port%
                    dbname:   %database_name%
                    user:     %database_user%
                    password: %database_password%
                    charset:  UTF8
    

    【讨论】:

    • 一个问题@Thomas,在此更改之后,我无法连接到我的数据库,我收到此错误:SQLSTATE [28000] [1045] 用户'root'@ 的访问被拒绝'localhost'(使用密码:否)。你知道为什么吗?
    • 确保您的 localhost 在 parameters.ini 文件中拥有正确的用户名/密码组合
    【解决方案2】:

    我也遇到了这个问题,发现配置中实际上不需要“connections”节点(请参阅http://symfony.com/doc/current/reference/configuration/doctrine.html#doctrine-dbal-configuration ...您只有在有多个连接时才需要connections节点)。

    在我的例子中,我在 Doctrine 之前的 AppKernel.php 文件中有 SonataCacheBundle。 Doctrine 在 Doctrine 初始化时设置了 "doctrine.connections" 参数,所以如果你在 Doctrine 初始化之前尝试在 SonataCacheBundle 中访问它,那么 "doctrine.connections" 还没有在容器中。

    重新排序 AppKernel.php 中的条目为我解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      • 2022-08-03
      • 2013-02-03
      • 2018-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多