izniburak / php-router

PHP Router, which also has rich features like Middlewares and Controllers is simple, useful and flexible router class for PHP.
https://github.com/izniburak/php-router/wiki
MIT License
238 stars 45 forks source link

Controller groups #66

Open alexanderthegreat96 opened 2 years ago

alexanderthegreat96 commented 2 years ago

Is to possible to use controller groups. As Laravel does.

Defining controller + group in the same spot and then applying all the routes to the parent controller?

izniburak commented 2 years ago

Hi @alexanderthegreat96 , You talking about Route grouping? If you are, did you check this documentation?

alexanderthegreat96 commented 2 years ago

Nope. You know how you use groups to define prefixes. How about using Controller groups.

Just like laravel does it. So when you specify the group , how about specifying a controller for the group without having to declare it in each controller method.

Like so

$route->group('group',function() { $route->get('list','listMethodWithingMyController') }, 'MyController::classs');

or

$route->controller(MyController::class)->group('my-group',function() { $route->get('list','listMethodWithingMyController') })

Understand now?

izniburak commented 2 years ago

Okay. For now, the Package no support such a usage like that but we can add this feature in next releases. I'll add it to my notes to implement it as soon as possible.

alexanderthegreat96 commented 2 years ago

Thank you. I really appreciate it.

AlexJMcloud commented 1 year ago

Okay. For now, the Package no support such a usage like that but we can add this feature in next releases. I'll add it to my notes to implement it as soon as possible.

There is a rational suggestion, what I sent you by mail with the processing of an array of routes, then there you can specify the controller for the group. And process a group with one controller and with different methods. Within the current version.