2

I've been following this with a fresh install of symfony2 and everything goes fine until I hit the step where it says

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

which then gets me the error

Bundle AcmeStoreBundle does not contain any mapped documents. Did you maybe forget to define a mapping configuration?  

I've followed the guide exactly other than in config.yml, where I had a custom URI connection string since I turned on auth. I don't believe this is the problem, but I'll post it anyways.

doctrine_mongodb:
connections:
    default:
        server: mongodb://root:password@localhost:27017
        options: {}
default_database: admin
document_managers:
    default:
        auto_mapping: true
4
  • Crazy question, but do you have any mapped documents? Commented Nov 27, 2013 at 0:06
  • How do I create a mapped document? I thought following that guide would create said document? I made a Document directory under the bundle and made a Product.php file. Update question since first code fragment is wrong. Commented Nov 27, 2013 at 0:14
  • And did you add annotiation or any other mapping to the document? Yml or XML or Annotiation? Where you describe the behavior for the "fields"? Commented Nov 27, 2013 at 8:33
  • Carreful, to have a right namespace however it could generate this error too Commented Dec 17, 2014 at 15:03

4 Answers 4

3

Aha, I've had this issue before. Keep Calm, you probably forgot to put < ?php

Sign up to request clarification or add additional context in comments.

Comments

2

I think you forgot the following step:

Add Mapping Information (http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html#add-mapping-information)

When I do not do that step, I am getting the same error as you. It's either you didn't do it, or you did that step wrong, so I suggest you have a look at that again.

1 Comment

+1 for pretty close - I had the wrong namespace "Acme\DemoBundle\Product" instead of "Acme\DemoBundle\Document" !
1

So to be clear: DoctrineMongoDBBundle looks for a package called Document inside the bundle. If your entities are stored somewhere else, eg in an Entity package you will get this error.

The solution in that case is to point doctrine to the right folder like so:

doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: test_database
    document_managers:
        default:
            auto_mapping: true
            mappings:
                AppBundle:
                    type: annotation
                    dir: Entity
                    prefix: 'AppBundle\Entity'

Comments

0

I solved this by adding an entry to my configs.yml file. My document had all the annotations needed, but this was also needed.

## config.yml

# MongoDB Configuration
doctrine_mongodb:
    document_managers:
        default:
            connection: default
            database: %database_name%
            retry_connect: %database_retry%
            retry_query: %database_retry%
            mappings:
                # Mapped bundles go here
                EccSpecialBundle: ~
                EccSuperBundle: ~

I realize this is not the solution to your problem, but I've run into this one a couple times now, so someone else might as well!

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.