Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Fatal error: Class 'mongoid' not found in

PHP 7, Mongo 3, Phalcon 3 incubator library 3.4 from

PROBLEM: trying to connect to mongo. In controller when i run ->save() i get fatal error ... Fatal error: Class 'mongoid' not found in


            # bootstrap
            $mongo = new MongoClient($dburl);
            return $mongo->selectDatabase($dbname);
            # controller...
            $user = new \MyApp\Models\Users();
            $user->email    = $this->request->getPost('email', 'striptags');
            $user->name = $this->request->getPost('name', 'striptags');
            $user->password = $this->security->hash($this->request->getPost('password'));

Any ideas on how to fix?

edited Sep '18

This helped...

instead of...

use Phalcon\Mvc\Collection;


use Phalcon\Mvc\MongoCollection;
class Somedata extends MongoCollection{
public function initialize()
    // set actual collection name

I also had to add the db name to the end of the connection string or i got authentication failure...

$di->setShared('mongo', function () {
        $mongo = new MongoClient('mongodb://mongousername:[email protected]:12345/mongodbname');
        return $mongo->selectDatabase('mongodbname');