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.phalconphp.com/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.



1.4k
Accepted
answer
edited Jan '15

http://docs.phalconphp.com/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
    ));
}


28.2k

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