steampixel / simplePHPRouter

This is a simple and small single class PHP router that can handel the whole url routing for your project.
MIT License
406 stars 117 forks source link

Grouping/Sub-Route Request. #62

Closed compilekaiten closed 2 years ago

compilekaiten commented 2 years ago

Create a group name, which becomes the Prefix for every route inside it.

Or is this already possible somehow?

Route::group('/prefix', function() {

    Route::add('/', function () {
        echo "This Route is: /prefix";
    });

    Route::add('/user', function() {
        echo "This Route is: /prefix/user";
    });

});
splashsky commented 2 years ago

I've already added this functionality in my fork. You can look at the code and implement a PR here, if you'd like.

https://github.com/splashsky/simplerouter/pull/10

steampixel commented 2 years ago

@compilekaiten I want to stay basic with this router. So I will not implement a grouping feature at the moment. But as @splashsky already mentioned you can use this code