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

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 https://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.



2.1k
Accepted
answer
edited Jan '15

https://docs.phalcon.io/en/latest/reference/namespaces.html

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
    ))->setName($key);
    $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
    ));
}


43.9k

Hi,

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

https://github.com/phalcon/album-o-rama