{"id":60,"date":"2015-03-30T10:04:16","date_gmt":"2015-03-30T10:04:16","guid":{"rendered":"http:\/\/dracony.org\/?p=60"},"modified":"2015-03-30T12:57:08","modified_gmt":"2015-03-30T12:57:08","slug":"replacing-controllers-with-middleware","status":"publish","type":"post","link":"https:\/\/dracony.org\/replacing-controllers-with-middleware\/","title":{"rendered":"Replacing controllers with middleware"},"content":{"rendered":"

Middleware is now a very popular topic in the PHP community, here are some of my thougts on the subject. First, let’s take a quick look at what middleware is ( if you already know about middleware you can skip this part):<\/p>\n

Short intro<\/strong><\/p>\n

The idea behind it is “wrapping” your application logic with additional request processing logic, and then chaining as much of those wrappers as you like. So when your server receives a request, it would be first processed by your middlewares, and then after you generate a response it will also be processed by the same set:<\/p>\n

\"Middleware\"

Middleware<\/p><\/div>\n

It may sound complicated, but in fact it’s very simple if you look at some examples of what could be a middleware:<\/p>\n