Phalcon Configure custom routes

By default, Phalcon will not use routing system to map http request uri to controller and action. This is different from other frameworks like zf2, laravel … But it is not a hard work to configure your custom routes.

Inject router into Phalcon Application by adding the following code to “app/config/services.php

Create new php file “app/config/routes.php

By default the URI information is obtained from the $_GET[‘_url’] variable, this is passed by the Rewrite-Engine to Phalcon, you can also use $_SERVER[‘REQUEST_URI’]

If you set the namespace for the controller in the file “app/config/loarder.php”

The router also need to set default namespace

$router->notFound just as it said by itself. For the not found page we also need add the http status code 404 in the action:


For more info about Phalcon routing please check:

Leave a Reply

Your email address will not be published. Required fields are marked *