Middleware is one of the important part of any application. The code which we want to stick between request/response life cycle which is not necessary part of our application logic. That is called as middleware.
Let take a example to know more about middleware.
1) Adding session support
2) Parsing query strings
3) Implementing rate-limiting
4) Sniffing for bot traffic
5) Adding logging
6) Parsing request JSON
7) Anything else related to the request/response lifecycle
Laravel's Implementation Step By Step:
For implement middleware we use HttpKernelInterface. In laravel 4.x we have Foundation/Application (In built functionality). By adding this we are able to integrate middle ware in laravel.
Middleware may be specified on controller routes like so: