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

Forwarding to a generic 404 page

I've built a 404 error page on the default module of a multi-module application.

Now, whenever I want to show the 404 page, I'm trying to forward to this controller/action on the default module but without success.

This is my code:

    'namespace' => '\Multiple\Home\Controllers',
    'controller' => 'error',
    'action' => 'notfound'

I returns the following error:

Multiple\Phrases\Controllers\ErrorController handler class cannot be loaded

What am I doing wrong?


A dispatcher is unique per module, I assume there are no global auto-loader for both modules, so the dispatcher cannot auto-load classes if the auto-loader in the other module is not available/loaded. You can better use a redirect if you want to forward between modules.

So, I should build a global auto-loader or I should keep all these controllers inside one module so that I can forward requests between them, right?


That could work, however if there are views associated to the controllers, I think the view component in the module maybe is pointing to the wrong directory. You may have to copy the views to both modules too.

I ended up creating a new module and moved all the other modules controllers to this new one so that I can forward requests between them.

Thank you.