Phalcon Multi-Module Routing Issues

Im attempting to use the multi module configuration for the Phalcon PHP Framework.

Im having an issue relating to the routing as one of my modules is inaccessible via url. It seems every time I try to access the defined modules uri, it tries to invoke the default modules namespace.

Project\Module1\Controllers\Module2Controller handler class cannot be loaded

The idea solution  => module1  => module2          => module1

In working to resolve this problem, I have verified that all paths and namespaces are correct. Ive combed through it with xdebug.

Ive created my project with Phalcon Devtools with the multi module type defined as it provided me with a skeleton to follow. As I am using this method, it provided a default routing method that interprets each registered module and binds it to a url. This does not seem to be working for me. This is the Phalcon project before interpretation.


$router = $di->get("router");

foreach ($application->getModules() as $key => $module) {
    $namespace = str_replace('Module','Controllers', $module["className"]);
    $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

Module Registration

    'module1' => array(
        'className' => 'Project\Module1\Module',
        'path' => __DIR__ . '/../apps/module1/Module.php'
    'module2' => array(
        'className' => 'Project\Module2\Module',
        'path' => __DIR__ . '/../apps/module2/Module.php'


$di->set('router', function () {
$router = new Router();


 return $router;

An example provided by Phalcon. This not exact to the Phalcon Tools implementation.

Any help is much appreciated.

$router->add("/module1", [
        'module'     => 'module1',
        'namespace'  => 'module1\Controllers',
        'controller' => 'index',
        'action'     => 'index',