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

How to create a 404 page?

hello I would like to create a simple page 404, but nothing more bone only that page is for understanding



77.7k
Accepted
answer

This will forward the dispatcher to a desired controller+action:

$di->setShared('router' ,function() use($config) {
    $router = new \Phalcon\Mvc\Router();
    $router->notFound(array(
        "controller" => "index",
        "action" => "route404"
    ));
    return $router;
});


81.2k

Thank you very much