-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[7.x] Ability to skip a middleware from route registration #32347
Conversation
Did you try this with the new route caching system? Does it still work? |
Looks like it is probably covered under the action being serialized. |
Fixed a small issue to resolve short alias names to class names before the exclusion check. Thanks. |
Awesome, thanks! |
@dsazup was it intentional that this doesn't applies to global middleware? |
Hey @driesvints, not really. I didn't realize the global middleware is being applied elsewhere, but now I see it happens in the http kernel. It would be really good to get it to work with global middleware though. 🤔 |
Is this renamed to withoutMiddleware? |
@decadence yes. |
I just tried this and didn't worked for me, i did tried with ->skipMiddleware(VerifyCsrfToken::class), and with ->withoutMiddleware(VerifyCsrfToken::class).... and nothing |
@Claw-Hammer This doesn't support excluding global middleware: #32404 |
Hello. Quite a few times I needed to skip a specific middleware for just one route. The current approach seems to be
$except
property in the middleware and then skipping it if the URL matches. This mostly works, but sometimes we do not know the exact URL, or we do not know the name of the route so that is not always the best solution.I would like to propose
skipMiddleware
method, which would be used like:Route::get('/something')->skipMiddleware(VerifyCsrfToken::class)
Route::get('/teams/create')->skipMiddleware(VerifyUserHasTeam::class)
Quite simple, but solves an annoying problem. Hopefully, I am not the only one running into this so I'd love to see this in the core. Please consider it and let me know if there is anything I need to change.
Thanks!