O'Reilly logo

Learning Phalcon PHP by Calin Rada

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the router component in a module

We will continue this chapter by creating the routes for our application. To do this, switch to the config directory, and create a file named routing.php with the following content:

<?php $di['router'] = function() use ($default_module, $modules, $di, $config) { $router = new \Phalcon\Mvc\Router(false); $router->clear(); $moduleRouting = __DIR__.'/../apps/'.ucfirst($default_module).'/Config/routing.php'; if (file_exists($moduleRouting) && is_file($moduleRouting)) { $router = include $moduleRouting; } else { $router->add('#^/(|/)$#', array( 'module' => $default_module, 'controller' => 'index', 'action' => 'index', )); $router->add('#^/([a-zA-Z0-9\_]+)[/]{0,1}$#', array( 'module' => $default_module, 'controller' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required