Php Symfony2 mongodb安装
我一直在关注新安装的symfony2,一切都很顺利,直到我达到了它所说的步骤Php Symfony2 mongodb安装,php,mongodb,symfony,Php,Mongodb,Symfony,我一直在关注新安装的symfony2,一切都很顺利,直到我达到了它所说的步骤 php app/console doctrine:mongodb:generate:documents AcmeStoreBundle 这让我知道了错误 Bundle AcmeStoreBundle does not contain any mapped documents. Did you maybe forget to define a mapping configuration? 除了在config.ym
php app/console doctrine:mongodb:generate:documents AcmeStoreBundle
这让我知道了错误
Bundle AcmeStoreBundle does not contain any mapped documents. Did you maybe forget to define a mapping configuration?
除了在config.yml中,我完全遵循了指南,在config.yml中,自从我打开auth之后,我有一个自定义URI连接字符串。我不认为这是问题所在,但无论如何我都会把它贴出来
doctrine_mongodb:
connections:
default:
server: mongodb://root:password@localhost:27017
options: {}
default_database: admin
document_managers:
default:
auto_mapping: true
我想你忘记了以下步骤: 添加映射信息()
当我不做这一步时,我会得到和你一样的错误。要么是你没有做,要么是你做错了那一步,所以我建议你再看看。啊哈,我以前有过这个问题。请保持冷静,您可能忘了放置
?php
我通过在configs.yml文件中添加一个条目解决了这个问题。我的文档包含了所需的所有注释,但这也是必需的
## 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: ~
我意识到这不是解决你问题的办法,但我现在已经遇到过几次了,所以其他人也可能会这样 需要明确的是:DoctrineMongoDBBundle在bundle中查找名为
Document
的包。如果您的实体存储在其他地方,例如在实体
包中,则会出现此错误
这种情况下的解决方案是指向正确的文件夹,如下所示:
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'
疯狂的问题,但你们有任何映射文档吗?我如何创建映射文档?我以为遵循那个指南就能创建出那个文档?我在捆绑包下创建了一个文档目录,并创建了一个Product.php文件。更新问题,因为第一个代码片段是错误的。您是否向文档添加了注释或任何其他映射?Yml、XML还是注释?在这里,您描述了“字段”的行为?carrele,它有一个正确的名称空间,但是它也可能会生成这个错误+1,非常接近-我的名称空间“Acme\DemoBundle\Product”而不是“Acme\DemoBundle\Document”!