php-router icon indicating copy to clipboard operation
php-router copied to clipboard

Controller groups

Open alexanderthegreat96 opened this issue 2 years ago • 5 comments

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?

alexanderthegreat96 avatar Apr 19 '22 09:04 alexanderthegreat96

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

izniburak avatar Apr 19 '22 21:04 izniburak

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?

alexanderthegreat96 avatar Apr 19 '22 21:04 alexanderthegreat96

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.

izniburak avatar Apr 19 '22 21:04 izniburak

Thank you. I really appreciate it.

alexanderthegreat96 avatar Apr 19 '22 22:04 alexanderthegreat96

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.

AlexJMcloud avatar Dec 28 '22 16:12 AlexJMcloud