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.

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.



3.9k
Accepted
answer
edited Jul '15

Resolved