I have tried the following example in order to display the collection count. Here is what I did:
<?php
$connection = new MongoDB\Driver\Manager(Mongo URI);
//echo phpinfo();
$collection = new MongoDB\Collection($connection, "new", "items");
$initialCollectionCount = $collection->count();
echo $initialCollectionCount;
?>
I am getting the following error:
Fatal error: Uncaught Error: Class 'MongoDB\Collection' not found in C:\xampp\htdocs\test\test.php:4 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test\test.php on line 4
What I did till now:
1) Downloaded the latest MongoDB drivers from the Pecl website for PHP 7.1.
2) added the DLL file to ext folder and edited the php.ini file.
3) Written code for the php and mongo Connection.
Kindly suggest me what I need to do to make my code run. Please note that I have added the System variable as PHP folder. There is nothing that I have not done till now.
Please suggest me the right track so my code get implemented.
require 'vendor/autoload.php';Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\test\test.php on line 2