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.

Call to method handle() on a non object

I hava a error,It says phalcon\Mvc\Application::handle(): Call to method handle() on a non object,my code like this

$application = new Application($di);
    // Register the installed modules
    $application->registerModules(
        array(
            'frontend' => array(
                'className' => 'Gkr\Frontend\Module',
                'path'      => '../apps/frontend/Module.php',
            ),
            'backend'  => array(
                'className' => 'Gkr\Backend\Module',
                'path'      => '../apps/backend/Module.php',
            )
        )
    );
    echo $application->handle()->getContent();

can you help me?

Hmm.. I have multiple modules in my app and I've never encountered this before.

I cannot even reproduce the same error. Anyone wanna take a bite on this?



96
Accepted
answer
edited Oct '14

i had the same problem.

changed the following:

$di->set('router', function() {
    $router = new Router();
    $router->add('/:controller/:action', array(
        'module' => 'test',
        'controller' => 1,
        'action' => 2,
    ));
});

to:

$di->set('router', function() {
    $router = new Router();
    $router->add('/:controller/:action', array(
        'module' => 'test',
        'controller' => 1,
        'action' => 2,
    ));
    return $router;
});

...and now it works.