php-router
php-router copied to clipboard
Group specific error pages and prefix error pages
I tried my best to do. I would be very happy if I could contribute. I did the question I asked today and a little more.
I added the following features;
Error pages created in groups are now specific to that group
$router->group('/test', function ($router) {
$router->get('/',function () use ($router) {
return 'text page';
});
$router->get('/blue',function () {
echo 'blue page';
});
$router->group('/testing', function ($rou) {
$rou->get('/',function () {
echo 'testing page';
});
$rou->error(function () {
echo 'testing error page';
});
});
$router->error(function () {
echo 'test error page';
});
});
'home@notfound' is now available in error function
$router->error('home@notfound');
route prefix can be set in error function regardless of group
$router->error('home@notfound',['prefix' => '/test']);
That's all, maybe it could have been better. That's as much as I can. I really need this feature
i tested it again with the last edits and it doesn't seem to be a problem. i've an idea to create custom pages based on error codes. i'll work on it.
idea;
$router->error('home@notfound',['errorCode' => 403]);
Hi @Venloress . Thank you for your effort. I will test your changes in locally and after that we can merge it with main branch.