Kioko Kiaza
Kioko Kiaza

Reputation: 1398

SonataMediaBundle You have requested a non-existent parameter "doctrine.connections" error

I have setup a SonataAdminBundle on my Symfony 2.1.2 project and it works correctly. Now I´m trying to setup a SonataMediaBundle but I get this error:

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



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

I copied the config parameters to config.yml as indicates the documentation. You can see it there: http://pastebin.com/wys11net

Any help or clue?

Thanks in advance

Upvotes: 0

Views: 2740

Answers (2)

cmenning
cmenning

Reputation: 630

I just ran into this problem as well, and found that the "connections" node is not actually required in the config (see http://symfony.com/doc/current/reference/configuration/doctrine.html#doctrine-dbal-configuration ... you only need the connections node when you have multiple connections).

In my case, it was that I had the SonataCacheBundle in the AppKernel.php file before Doctrine. Doctrine sets the "doctrine.connections" parameter when Doctrine initializes, so if you try to access it in SonataCacheBundle before Doctrine has initialized then "doctrine.connections" is not in the container yet.

Reordering the entries in AppKernel.php fixed the issue for me.

Upvotes: 1

Thomas
Thomas

Reputation: 222

Looks like you're missing the Connections node inside the Doctrine > DBAL's node, aswell the specification of a default connection (among multiple connections, if that would be the case). An example of the right template would be like

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

Upvotes: 2

Related Questions