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.

Mongo: Maximum recursion depth exceeded

I'm brand spanking new at Phalcon and working on getting Mongo connected to a remote host. I seem to be connected to the db but trying to instantiate the model that extends \Phalcon\Mvc\Collection gives me the following error.

Fatal error: Phalcon\DI::get(): Maximum recursion depth exceeded

Any help is appreciated.

Show your code

edited Mar '14

The connection to mongo in the bootstrap is:

$di->set('mongo', function() {
    $config = Registry::get(CONFIG);
    $connect = array('username' => $config->mongo->username,
                     'password' => $config->mongo->password );
    $mongo = new Mongo($config->mongo->host, $connect);
    return $mongo->selectDb($config->mongo->name);
}, TRUE);
$di->set('collectionManager', '\Phalcon\Mvc\Collection');

In the controller I've tried

$user = User::find();

which shows: Fatal error: Phalcon\DI::get(): Maximum recursion depth exceeded

$user = new User();

Which shows the error: Fatal error: Phalcon\DI\Service::resolve(): Maximum recursion depth exceeded

The User model is simply

class User extends \Phalcon\Mvc\Collection
{

}


85.3k
edited Oct '14

This kind of fatal error is raised when the extension detects an infinite loop. Infine loops could make the execution unstable because PHP could be out of memory. Try adding a debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) in the 'mongo' and 'collectionManager' service definition to check if there is a cyclic dependency in one of your services.



3.5k
Accepted
answer
edited Oct '14

Turned out that I needed to add Manager to:

$di->set('collectionManager', '\Phalcon\Mvc\Collection\Manager');