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

Routing not working in Multiple-Factory-Default

I have created yesterday new project with phalcon developer tools with option "multi".

I have got structure like this:

app

--> Core

--> User

    --> Controller

         --> SecurityController.php

     --> View

         --> Security

              --> login.phtml

config

public

In config/services.php I have changed routing to look like:

$di['router'] = function () {

$router = new Router();
$router->add('/login', array(
                            'module' => 'User',
                            'controller' => 'Security',
                            'action' => 'login',
                    ));
 return $router;

};

But when I am trying to access https://example.com/login, I am getting this error:

SecurityController handler class cannot be loaded

Can someone please let me know what I am doing wrong?



6.2k

This seems to be working when I will add

$router->setDefaultNamespace("TrebionCRM\User\Controller");

But then it doesn't work if I will add e.g.

$router->add('/index', array( 'module' => 'Core', 'controller' => 'Index', 'action' => 'index', ));

so it is working then for just one Module and when I am going to https://example.com/index I am getting this exception

TrebionCRM\User\Controller\IndexController handler class cannot be loaded

Why is it trying to load it for User module, not Core module?