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

Routes - Need a Pointer on Public/subdir

First of all, let me note that I am reading the routing docs...but not 100% certain what I am loking for. So, I think this will amount to something easy and I need a pointer in the correct direction.

I am writing a multi module site (backend and frontend). Started with the great example at: https://github.com/phalcon/mvc/tree/master/multiple-shared-layouts

I am trying to route the following url: /localhost/test to a layout in /apps/backend/layouts/test.phtml as such:

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

What I get is a printout of the file contents of the /test directory (Which contains all the supporting media files...so I see an images directory, a css directory, etc...) This is presented instead of the layout defined in /apps/backend/layouts/test.phtml which should reference said support files.

Any pointers would be greatly appreciated!!


you have actual /test folder in the public directory? if so you need either to add a .htaccess to it or rename the folder. Phalcon .htaccess is going to route all calls from none existing directory


here is my folder skeletopn


and this is my route code


$router = new Phalcon\Mvc\Router();
 * Create Route Admin Backend
$routing = array(
    '/admin/dashboard' => array(
        'namespace' => 'app\controllers\admin',
        'controller' => 'dashboard',
        'action' => 'index'),
    '/admin/system' => array(
        'namespace' => 'app\controllers\admin',
        'controller' => 'system',
        'action' => 'index'),

foreach ($routing as $k => $v) {
    $router->add($k, $v);

return $router;

it's work for me