ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How many ways you can add middleware in controller .?

what is middleware in laravel ?

user-image
تم إضافة السؤال من قبل Aijaz Ahmad , Sr Php Developer , Vcare Software solutions Pvt Ltd
تاريخ النشر: 2018/01/10
Rashedul Hoque
من قبل 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!

المزيد من الأسئلة المماثلة