I've been using the Slim Framework (v2) for a little while now to develop my user management system.
They recently released Slim 3, and according to the upgrade guide,
Slim v3 no longer has the concept of hooks. Hooks were removed as they duplicate the functionality already present in middlewares. You should be able to easily convert your Hook code into Middleware code.
I'm not quite sure if I believe this. Slim's middleware allows you to modify the request before it hits your main application, or modify the response before it is sent out to the client.
However, this says nothing of modifying the behavior of the application itself, which hooks can do easily - the application simply anticipates points in the code where someone might want to modify the behavior, and call applyHook
accordingly.
From what I can tell, the only way to modify the core behavior of an application via middleware is via exceptions - the middleware throws an exception, which the core application catches, and then does something else. But this seems to me an abuse of the framework, and I have a hard time believing that this is what they mean.
Do hooks really "duplicate the functionality already present in middlewares"?