-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[8.x] Fix router for array action within namespaced groups #34784
Conversation
I think this is a major breaking change? Stops people from using namespaces? |
That said, I agree the namespacing feature maybe isn't so useful anymore if people are mostly using class notation now, so we maybe could consider making your proposed behaviour the default in Laravel 9, and possibly going further and removing namespacing stuff. |
I remember, the possibilty of referencing methods in routes was added in 5.6 in the PR #24385 The unexpected thing happed when I only turned the method calls around: The second way requires '\'. but not the first way. |
68888b7
to
98837ce
Compare
@GrahamCampbell Route::middleware('auth')->get('{task}/edit', ['\\'.TasksController::class, 'edit']);
Route::middleware('auth')->get('{task}/edit', [ TasksController::class, 'edit']); I think with the route cache the production performance will be the same. |
98837ce
to
285110a
Compare
285110a
to
0283a7e
Compare
I'm confused. Of course it doesn't work. You said your RouteServiceProvider defines a namespace? So, it will be prepended. This is exactly how Laravel 7.x worked. |
No plans to change this behavior. |
While coding in a typical project I found that the router has an inconsistency:
This does not work in
web.php
since the root namespace of the group gets prepended to the imported controller.Error: App\Http\Controllers\App\Http\Controllers\TasksController does not exist.
But the original feature does not expect that: #24385
===========
There are 2 solution:
1- if we add a backslash at the start of controller '\'.TasksController:
2- we call the middleware method "After" controller