【发布时间】:2018-10-05 16:20:13
【问题描述】:
Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionException: Server at localhost:27017 reports wire version 0, but this version of libmongoc requires at least 3 (MongoDB 3.0)
我有 PHP 7.0.13、MAMP 和 MongoDB。已安装 PHP 的 MongoDB 扩展。
我有以下几点:
<?php
ini_set('display_errors', 'On');
require 'vendor/autoload.php';
var_dump(extension_loaded('mongodb'));
echo phpversion('mongodb')."\n";
$m = new MongoDB\Driver\Manager("mongodb://localhost:27017");
// Query Class
$query = new MongoDB\Driver\Query(array('age' => 30));
// Output of the executeQuery will be object of MongoDB\Driver\Cursor class
$cursor = $m->executeQuery('testDb.testColl', $query);
// Convert cursor to Array and print result
print_r($cursor->toArray());
?>
在这种情况下,“电线”指的是什么,有人有解决这个问题的方法吗?
【问题讨论】:
-
您使用的是什么版本的 MongoDB 服务器?错误消息表明您的驱动程序至少需要 MongoDB 3.0,并且您的服务器似乎是旧版本或未知版本。
标签: php mongodb mamp libmongoc