I don't like the new mongo, MongoDB requires several libs in PHP7.
MongoClient (deprecated) in php 5 is much more convenient and easier!
I decided to run a script and compare the two versions, and the results are pretty amazing:
MongoDB (PHP 7.0.2)
$client = new MongoDB\Client( 'mongodb://root: password@localhost :port', ['readPreference' => 'secondaryPreferred'] ); $db = $client->selectDatabase('namedb'); $collection = $client->selectCollection('namedb', 'test'); $document = $collection->findOne(['_id' => 'works']); var_dump($document); $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); echo '<br><br>Page generated in ' . $total_time . ' seconds.';
Mongo / MongoClient (PHP 5.6.17)
$db = new MongoClient('mongodb://root: password@localhost :port'); $c = $db->namedb->test; $a = $c->findOne(array("_id" => 'works')); var_dump($a); $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); echo '<br><br>Page generated in ' . $total_time . ' seconds.';

Anyone else having this problem? I can not find any benefit in using the new version of MongoDB, all the problems!
source share