Disable default routes
$router = new Phalcon\Mvc\Router(false);
Add a notFound
method
$router->notFound(['controller' => 'index', 'action' => 'error404']);
Add a method to controller
public function error404Action() {
$this->view->setTemplateBefore('public');
$this->response->setStatusCode(404, 'Not Found');
$this->view->pick("index/error404");
}