I had an old ZF (actually ZF1) application laying around, so i decided to play a little bit with laminas/mezzio to see how it works and if updating would be possible. So as it is an old ZF1 application, laminas-mvc
seems the way the go, so i started with https://github.com/laminas/laminas-mvc-skeleton. I got it up and running very quick, but soon when i started to extend it i hit a wall. I think the documentation provides the technical guides but i am missing some conceptual insights and how to connect different parts.
The first thing i actually wanted to implement is authentication. Just a POC. I figured middleware is the place to look first but i got stuck pretty soon. With middleware in general. Looking at the docs of laminas-mvc
only point to laminas-mvc-middleware
which provides a recipe to replace the controller dispatching with defined middleware. But why should i use MVC and then replace the controller, i want to use middleware on top of that, otherwise i could just use mezzio
. Speaking of mezzio
, its documentation does not help either as the middleware instantiation and handling seems to be done in significant different manner than in laminas-mvc
.
I also looked at laminas-authentication
in aspiration it would provide a drop in solution to my problem. But it also lacked the part on how to integrate with a laminas-mvc
application.
So in essence my questions are:
- How would you integrate middleware without losing the controller dispatching mechanism?
- If i would better off without using middleware, how would you then setup something like
laminas-authentication
? - If 2 is true, how would one use already present solutions like mezzios authentication middleware?