Laravel 11 Middleware #49992
Unanswered
julien-fontaine
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I would like to suggest an improvement about the way we are defining middleware in Laravel 11. I know that it is not released yet, but I feel like this part is going in the wrong way.
The way we have to define them now, makes harder Laravel upgrade, and any new middleware should now be specified as a breaking change in the upgrade guide.
Also, it prevents us to define a specific order for the existing middleware, and middleware that we will add in our application. This PR try to fix this issue, but IMO, it brings us back to what we were doing in Laravel 10 while requiring us to use another way to remove/add middlewares, whereas the sort and this could be done in a single place.
Lastly, I feel the way the application is working is less explicit when used middleware are defined in the vendor.
Wouldn't it be better to keep it simple, and have a method
withMiddleware
that requires a closure returning an array of middleware we want to use? Here is an example of what I'm suggesting:@taylorotwell Sorry for the ping, I think you are the most relevant people to answer this idea.
Any other thoughts/solutions are welcome!
Beta Was this translation helpful? Give feedback.
All reactions