-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Passing middleware configuration as list of strings #13
Comments
I'm in the same situation. There is a focus on interoperability in Mezzio and laminas-mvc to standards, but at the same time it is missing between Mezzio and laminas-mvc or the handling is different. I would therefore welcome a harmonization. |
When @Xerkus came up with the new As for being forward compatible, you're right that this is a bit cumbersome change (also having to add If it's any help: in our project this was more or less a non-issue because we already abstracted away this verbose array-based route setup:
in the
we have some more helper functions for backend middleware routes and admin middlware, which prepend Login middleware and stuff in front of the You could rewrite your routes now using the old syntax and then would just have to use the new call to |
object instead of array removes a dangerous uncertainty of config merging. middleware declared as arrays will be merged resulting in something unexpected that is virtually impossible to notice from just a code review. |
So if we want to avoid dangerous config merging, why wont we add an RFC to mezzio router aswell? Imho, synchronizing this in some way would help alot as I really dont get why we should make migrations such a PITA. So having some kind of "PipeSpec" in the mezzio-router would at least help. Another way could be a dedicated Option in the config which explicitly enables the array config "at own risk" and thus only gets merged when manually added. I personally have to say, that as an advanced user, this kind of protection bothers me. I would say, there should be at least a way to have this achieved. sure, I could add some kind of Route builder, as the structure might change in mezzio anyways due to switch from zend-router to fastroute. I'll give this a shot. |
As a user, I want to map a route to a middleware, not to a controller. But I have to add I think the technical problem is clear, but the question is if we are pushing an internal problem to the user? |
There is no merging of Routed Middlewar config, is there? So it's not an issue there.
How would you do such a migration? IMO when migrating from mvc to Mezzio there is no direct copying the route config from mvc to Mezzio. Besides different syntax, the whole pipe is different. Because there is no global middleware pipe in mvc, I add every middleware in all route Honestly, I don't get why that |
That's different issue. The explicit |
@rieschl
|
Yes I read that, but do to config merging there's no other way around, is there? Despite migrating controllers to middleware from bottom up. |
@rieschl There is a config merge process. And regarding the route configuration: And sure, the global pipeline needs to be configured when migrating to mezzio. But it helps to migrate step-by-step without the need to run mezzio in parallel. And thats what we want to achieve. |
Initial reason to introduce PipeSpec was security focused: a route that would allow arbitrary 'middleware' parameter to be injected could lead to execution of any middleware or combination. Setting controller to As for the plain array, it was not brought back because of how config merging works: arrays with numeric keys will append and result in unpredictable pipelines. Route definitions are getting overridden with shared modules. I can suggest a listener on dispatch event, before middleware dispatch, that would wrap array in |
Plenty of security additions recently made to this library. Glad to hear that. I dont think that this feature will land here and thus, closing it. Thanks anyways. |
Feature Request
Summary
I am migrating from
laminas-mvc
middleware handling to this package and I've realized a difference I want to discuss.Mezzio
middleware
definition and Laminas MVCmiddleware
definition both support a list of multiple Middlewares (a so-called "pipe") in form of strings matching the FQCN of the middleware.This package does not. Instead, one has to implement some (imho) hard to understand configuration:
If one is familiar with Mezzio or the old configuration, it is hard to understand why this component requires to instantiate that pipe specification.
In order to prepare a project to be forward compatible to Mezzio so one can step-by-step migrate to Mezzio by converting existing routes to the middleware definition, I see a problem with this instantiation.
In our company, we are using MVC but want to migrate to Mezzio when we finished converting all controllers (which are around 500+ and thus wont be done in a single step). If we now have to specify
new Pipespec
for allmiddleware
keys, we have to remove this again when migrated to mezzio.Summary
Is there any reason why we should not support a list of strings as array definition?
If not, I am fine with creating a PR to support that along with the
new PipeSpec
definition.This would also provide backwards compatibility to old
laminas-mvc
middlewares (atleast these users only have to change the interfaces of their implementation rather than converting a whole bunch of configuration files).The text was updated successfully, but these errors were encountered: