riverside / php-express

:horse: PHP micro-framework inspired by Express.js
https://riverside.github.io/php-express/
MIT License
26 stars 10 forks source link

error 404 method (notFound) #6

Closed RWDevelopment closed 1 year ago

RWDevelopment commented 1 year ago

has php-express default error (notFound) method to show 404 error page ? any hints to write this ? how to do it ?

riverside commented 1 year ago

@RWDevelopment By default, there is not such a method. But you can use something like this:

$app->all('.*', function($req, $res) { $res->status(404)->send('Page not found'); }); or $app->all('.*', function($req, $res) { $res->render('path/to/errors/404')); $res->status(404); });

Note: insert the code right before $app->run();

RWDevelopment commented 1 year ago

thanks, it works fine