I’m currently using ZF3 with a large code base and I want to start writing middleware. As of Zend/mvc 3.1 you can create an array of middleware to be piped for a given route/path in the configuration; great feature. See the following link for some reference; https://www.jamestitcumb.com/posts/middleware-in-zend-mvc. However, I have not seen the capability to specify a set of middleware to be run on every request (ex. ip filter, CORS, auth, logging etc.) like you can in Zend Expressive. One can accomplish this in Zend Expressive by piping middleware before the routing middleware; makes sense. Does this capability exist in ZF3?
No, this feature does not exist. It can be done within event listeners by having the listener pull the request from the event, pass it to the psr7bridge to convert it, and then dispatch your middleware or pipeline with it. If you do, I’d suggest passing the MvcEvent as a request attribute.