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

about router notFound method

routes.php

$router->notFound(
    array(
        "controller" => "index",
        "action"     => "error"
    )
);

IndexController.php

public function errorAction($code = '404')
{
    $this->response->setStatusCode(404, 'Not Found');
}

When i try to access for ex: /test:

TestController handler class cannot be loaded

Why router notFound method doesnt working?

Beacause by default there are auto routing working in phalcon. Just put false in Router constructor. https://docs.phalcon.io/pl/latest/reference/routing.html#default-behavior



58.1k

Beacause by default there are auto routing working in phalcon. Just put false in Router constructor. https://docs.phalcon.io/pl/latest/reference/routing.html#default-behavior

Can i use with autorouter? Because of i want to use only show error page when router not found.

When i disable autorouter, should i add to routes all syntaxes?

You don't need to add all syntaxes, you just can add auto-route yourself. Just read docs there.