Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How many ways you can add middleware in controller .?

what is middleware in laravel ?

user-image
Question ajoutée par Aijaz Ahmad , Sr Php Developer , Vcare Software solutions Pvt Ltd
Date de publication: 2018/01/10
Rashedul Hoque
par Rashedul Hoque , Sr. Software Developer , Orko Health Ltd.

There are many more cases where you would like to use a middleware.

  • Using a middleware to confirm the incoming route request API key. Assuming you are building an API.
  • Rate-limiting a service call.
  • Change the site language based on locale.
  • Enable site-wide maintenance.
  • Sniffing bot traffic.
  • Logging.

You can implement middleware in different form based on requirements.. If you follow L5.6 doc. you can find :

Global Middleware

  • If you want a middleware to run during every HTTP request to your application

Assigning Middleware To Routes

  • If you would like to assign middleware to specific routes,

Middleware Groups

  • Sometimes you may want to group several middleware under a single key to make them easier to assign to routes

 

Hope this help. Thanks!

More Questions Like This