We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Service 'Module' wasn't found in the dependency injection container

Assume that we have the next code:

...
    $app = new \Phalcon\Mvc\Application($di);
    $app->registerModules(array(
        'content' => array(
            'className' => 'Content\Module',
            'path' => '../modules/content/Module.php'
        ),
        'auth' => array(
            'className' => 'Auth\Module',
            'path' => '../modules/auth/Module.php'
        )
    ));
    echo $app->handle()->getContent();

I losed many hours in reading manuals and debugging getting the next exception: Service 'Module' wasn't found in the dependency injection container

It was caused by mistake: 'classname' instead of 'className' in code.

I think that this post help people save time, because the text of exception is not helpful. 'array-orientated programming' style of this part of framework and my inattention caused this awful error.



12.3k
Accepted
answer
edited Jul '15

Resolved