首页 > 解决方案 > 带有 symfony 3.4 的 mongodb 地图集

问题描述

我有 symfony 3.4 并使用过 Doctrine MongoDB Bundle

"doctrine/mongodb-odm": "1.1",
"doctrine/mongodb-odm-bundle": "3.4",

我已经在本地安装了 mongo 并与以下配置一起使用,效果很好。

mongodb_server: 'mongodb://mongo:27017'
mongodb_collection: test
doctrine_mongodb:
    connections:
        default:
            server: "%mongodb_server%"
            options: {}
    default_database: "%mongodb_collection%"

但是现在我尝试访问 mongodb atlas 集群,此时我遇到了以下错误。

MongoClient::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known

我试图使用实际凭据作为演示进行访问

mongodb_server: 'mongodb+srv://<username>:<password>@clustertesting.osnmb.mongodb.net/<dbname>?retryWrites=true&w=majority'
mongodb_collection: test

标签: mongodbsymfonymongodb-atlas

解决方案


推荐阅读