We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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.

Multiple Module

I have set up MVC structure to use Modules in order to separate backend and frontend. But I get this error 'IndexController handler class cannot be loaded'.

My reference is http://docs.phalcon.io/en/latest/reference/applications.html.

I have a feeling it is something to do with bootstrap or autoloader file. Unfortunately I can't figure out the solution to have it working.

edited Jan '15


foreach ($application->getModules() as $key => $module) {
    $namespace = sprintf("Project\%s\Controllers", ucfirst($key));
    $router->add('/'.$key.'/:params', array(
            'namespace' => $namespace,
            'module' => $key,
            'controller' => 'index',
            'action' => 'index',
            'params' => 1
    $router->add('/'.$key.'/:controller/:params', array(
            'namespace' => $namespace,
            'module' => $key,
            'controller' => 1,
            'action' => 'index',
            'params' => 2
    $router->add('/'.$key.'/:controller/:action/:params', array(
            'namespace' => $namespace,
            'module' => $key,
            'controller' => 1,
            'action' => 2,
            'params' => 3



Without some code, and some apache error logs, wa can't help you very much ... but,

usually, these kind of errors happens when modules directories can't be finded by phalcon. Have a look at theses github repos:

https://github.com/phalcon/mvc for different kind of mvc apps