Handling 404
Handling 404 errors in your project


404 with Leaf Core Router

Leaf's core router has specially prepared for 404 errors, and is bent on giving users full control over displaying this error

For this reason, we've prepared the set404() method, which takes in a function, let's take a look

$leaf->set404(function () { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); echo '404, route not found!'; });
And that's all...It's that simple.
You can even display an HTML/PHP page using Leaf Core's Response
$response = new Leaf\Core\Http\Response(); $leaf->set404(function () use($response) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); $response->renderHtml(''); });

404s with custom routers

Since leaf has nothing to do with routing in this case, handling 404s will have to be done in a way befitting the router you are using. Read the documentation of the router you are using for more info

Next Steps

Leaf Dates
Named Parameters