In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to set the function of middleware in Laravel6". In daily operation, I believe that many people have doubts about how to set up the function of middleware in Laravel6. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubt of "how to set the function of middleware in Laravel6". Next, please follow the editor to study!
Taylor Otwell added the ability to set up middleware for specified queue tasks in Laravel 6 so that we can execute some business logic before performing certain queue tasks:
This [pull request] adds an easy way to have job specific middleware for queued jobs. Global job middleware were actually already possible by calling Bus::pipeThrough ([]) in a service provider during the application boot process... These middleware provide a convenient location to wrap jobs in some logic before they are executed.
We can define the middleware () method in the Job class to set the corresponding middleware, which returns an array of middleware object instances, so you can define multiple middleware:
Public function middleware () {return [new SomeMiddleware];}
The following is the sample code for the middleware, which is not much different from the previous middleware definition, except that the $request parameter is replaced with $command:
Class SomeMiddleware {public function handle ($command, $next) {/ / Do something... Return $next ($command);}}
In addition, you can dynamically specify middleware when you distribute a task, which automatically merges with the middleware returned by the middleware () method defined in the task class:
SomeJob::dispatch ()-> through ([new SomeMiddleware])
This feature will be available in Laravel 6, which will be released later this month, and you can see more details in this Pull Request.
At this point, the study on "how to set up the function of middleware in Laravel6" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.