Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/29/2022 in all areas

  1. It does explain them. While this is not in the manual, Laravel Middleware is an implementation of the Chain or Responsibility OOP Design Pattern. It is essentially a linked list of classes, each with a handle() method, and the HTTP request gets passed along and the handle() method is run. Once the handle method is complete, the next() method is called which will run the next handler. All the handlers are run, unless one of them interrupts the process rather than calling it's next() method. From the manual: So all the middleware handler classes in the $middleware array are run for every HTTP Request. If you have your own custom middleware you would also want run for every request, the manual page you posted shows you how you write one, which again just has to follow the same rules as any of the other middleware. Obviously there are other types of handlers that should only be applied to certain applications. For example, a Web application will likely have very different requirements than a REST api that is used by a Mobile application has. One very simple example of this difference is that a Web application will probably use cookies, whereas a mobile application will probably use tokens and assume its own local storage and configuration. Another example would be a web app implemented CSRF protection for web forms, where a mobile app won't have that, because it's not utilizing HTML client forms. So this is where Laravel groups up a set of associated Middleware handlers generally applicable to one application type. As you can see the web middleware group comes with the list of handlers you posted. Again you can add and subtract and customize this. This is fairly self explanatory I think. You are just given a convenient tag name for a handler to be used with specific routes to handle things like authentication and permissions. When defining a route, you are able to specify the list of middleware keys for the specific middleware handlers you need to have processed when that route is accessed. There are a few different ways to set up your routes. So there are some additional middleware options that might be of value, relative to how you defined your routes, especially if you are adding routes to a middleware group.
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.