Reputation: 2810
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
Upvotes: 2
Views: 3080
Reputation: 530
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'
Upvotes: 1
Reputation: 1510
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!
Upvotes: 0
Reputation: 193
Aha, I've had this issue before. Keep Calm, you probably forgot to put < ?php
Upvotes: 3
Reputation: 36784
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.
Upvotes: 2