Right way to define MongoDB in config.yml

断了今生、忘了曾经 提交于 2019-12-24 17:27:35

问题


I'm using MongoDB in my project but apparently Doctrine update their bundle and now I'm having issues if I run "composer update" command. This is my doctrine.yml file:

# ODM
doctrine_odm.mongodb:
  connections:
    default:
      server: mongodb://%mongo_host%:%mongo_port%
      options: {}
  default_database: %mongo_database%
  document_managers:
    default:
      auto_mapping: true

But I get this error:

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] There is no extension able to load the configuration for "doctrine_odm.mongodb" (in /var/www/html/kraken/app/config/doctrine.yml).

If I use this other configuration:

# ODM
doctrine_mongodb:
  connections:
    default:
      server: mongodb://%mongo_host%:%mongo_port%
      options: {}
  default_database: %mongo_database%
  document_managers:
    default:
      auto_mapping: true

Then the error transform to this one:

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException] The service "doctrine_mongodb.odm.default_configuration" has a dependency on a non-existent parameter "doctrine_mongodb.odm.default_commit_options". Did you mean one of these: "doctrine_mongodb.odm.default_connection", "doctrine_mongodb.odm.default_document_manager"?

What I'm doing wrong or what I'm missing?


回答1:


Just add (I have had the same problem few minutes ago when I ran composer update):

doctrine_mongodb:
    default_commit_options: ~



回答2:


Quick answer. This seems to be a known issue.

https://github.com/doctrine/DoctrineMongoDBBundle/issues/222

The solution is to add a default option:

doctrine_mongodb:

default_commit_options: ~


来源:https://stackoverflow.com/questions/21555560/right-way-to-define-mongodb-in-config-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!