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

Multi-module Router Problem

I have a virtual host dev.phalcon.com https://dev.phalcon.com/sample default router : index/sample/index but I want to set https://dev.phalcon.com/sample default router as sample/index/index

In other words,there is only one https://dev.phalcon.com/sample ,sample is module name. But Now sample is Controller name



58.4k

in router $router->setDefaultModule("frontend"); $router->setDefaultAction("index"); $router->setDefaultController("index");



13.8k

I have two Module, sample1 ,sample2 $router->setDefaultModule("sample1");

But https://dev.phalcon.com/sample2 ,I get some error: Fatal error: Uncaught exception 'Phalcon\Mvc\Dispatcher\Exception' with message 'Multiple\Sample1\Controllers\Sample2Controller handler class cannot be loaded'



13.8k

https://dev.phalcon.com/sample2 default router is sample1/sample2/index Not the router sample1/index/index



58.4k
edited Oct '14

I have two module frontend, admin, my in router

$router->removeExtraSlashes(true);
/*===========================Frontend=====================================*/
            $router->setDefaultModule("frontend");
            $router->setDefaultAction("index");
            $router->setDefaultController("index"); 

/*=============================Backend====================================*/
            $router->add("/admin", array(
                'module' => 'admin'

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

            $router->add('/admin/:controller/:action', array(
                'module' => 'admin',
                'controller' => 1,
                'action' => 2,
            ));
            $router->add(
                "/admin/:controller/:action/:params",
                array(
                'module' => 'admin',
                    "controller" => 1,
                    "action"     => 2,
                    "params"     => 3,
                )
            );


13.8k

$router = new \Phalcon\Mvc\Router();

$router->setDefaultModule("sample1");

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



13.8k

https://dev.phalcon.com/sample2 default router is sample1/sample2/index Not the router sample1/index/index

Not Work ,Why



13.8k

Now I am writing a framework base phalcon, Module name is user-defined.