Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group specific error pages and prefix error pages #55

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mertgibi
Copy link

@mertgibi mertgibi commented Jul 14, 2021

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

mertgibi added 6 commits July 14, 2021 17:11
- Added creating custom error pages for groups
- Added route prefix for error function
- `class@method` is now available in error function

You can browse the test folder for usage examples of the added features.
=> https://github.com/venloress/php-router/tree/venlo/tests
- Added creating custom error pages for groups
- Added route prefix for error function
- `class@method` is now available in error function

Thanks for your time
According to my last edits. Fixed an issue where I couldn't reach the default error page
@mertgibi
Copy link
Author

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]);

@izniburak
Copy link
Owner

Hi @Venloress . Thank you for your effort. I will test your changes in locally and after that we can merge it with main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants