1

I am doing my first steps with mongodb in symfony 2.4, following the manual instructions here. After successfully setting up and running mongodb server, I am trying to generate my first getters and setters with the following instruction:

php app/console doctrine:mongodb:generate:documents AcmeDemoBundle

But all I get is this error message:

[Symfony\Component\Config\Definition\Exception\InvalidTypeException] 
Invalid type for path "doctrine_mongodb.connections.default_database". 
Expected array, but got string 

Here is what seems to be my conflicting configuration:

# Doctrine Mongo DB Configuration
doctrine_mongodb:
  connections:
    default:
      server: mongodb://localhost:27017
      options: {}
    default_database: test_database
    document_managers:
      default:
        auto_mapping: true

namely:

default_database: test_database

It sounds strange that a default database is expected to be an array. I tried this anyway

default_database: [ test_database ]

and got this other error message:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "0" under "doctrine_mongodb.connections.default_database"

This post about mongdb doctrine configuration gives a lot of info about more advanced options. I tried another database name:

default_database: hello_%kernel.environment%

with no more luck (got the first error message).

Any idea what I am doing wrong ? Any hint will be welcome ! Thanks.

2 Answers 2

6

Be careful with yml the indentation is "strict". default_database must be at the same hierarchical place that connections. (Sorry for English).

# Doctrine Mongo DB Configuration
doctrine_mongodb:
  connections:
    default:
      server: mongodb://localhost:27017
      options: {}
  default_database: test_database
  document_managers:
    default:
      auto_mapping: true
Sign up to request clarification or add additional context in comments.

Comments

0

Oh, ok, I got it right... so "default_database" should be nested at the same level as "connections"... That was not too difficult :/

doctrine_mongodb:
  connections:
    default:
      server: mongodb://localhost:27017
      options: {}
  default_database: test_database
  document_managers:
    default:
      auto_mapping: true

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.