Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How many ways you can add middleware in controller .?

what is middleware in laravel ?

user-image
Question added by Aijaz Ahmad , Sr Php Developer , Vcare Software solutions Pvt Ltd
Date Posted: 2018/01/10
Rashedul Hoque
by 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