I'm using http://docs.php.net/manual/en/mongodb.tutorial.library.php and when I use the example they provide, I get a PHP Fatal error: Class 'MongoDB\Collection' not found. I'm using composer and even without the require mongodb\mongodb I get and a MongoDB\Driver\Manager Object if I print the $manager suggesting that it is using one MongoDB that it's not the one that I've installed (because it is not installed, at least via composer).
Any idea to find that MongoDB or to solve my problem?
SOLVED: Because I'm using this from command line and not from Luracast/Restler, I need to require the autoload on the construct during the command line
namespace NES\Utils;
use MongoDB;
class Mongo
{
private $manager;
private $collection;
public $result;
function __construct($collection)
{
require_once "../../vendor/autoload.php";
$this->manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$this->collection = new MongoDB\Collection($this->manager,"nestories.queue");
$result = $this->collection->find( [ 'teste' => 'teste'] );
print_r($result);
}
}
Regards
MongoDBisn't a class on its own by the look of it, souse MongoDB;is probably causing issues.