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

Same Route to multiple Namespaces

Hi, I have the namespace Icon\Controllers and Icon\Net\Controllers

I'm using $loader->registerNamespaces to register both namespaces and setting $dispatcher->setDefaultNamespace("Icon\Controllers"); but I don't know how to make Icon\Net\Controllers accessible

The controllers from Icon\Controllers are accessible through https://localhost/Controller_Name

I wanted to make \Icon\Net\Controllers accessible through https://localhost/Controller_Name as well.

I already tried making it work using routes, by adding these two routes, but they didn't work:


$router->add('/:controller', array(
        'controller' => 1
));

$router->add('/:controller', array(
        'namespace' => 'Icon\\Net\\Controllers',
        'controller' => 1
));


2.6k

How should the router know if it should load the controller from Icon\Controllers or \Icon\Net\Controllers? Either place the controllers in the same namespace or use modules to use controllers from different packages.



1.4k

Is there any way to have the same namespace divided into several folders?