In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use Thinkphp6.0 middleware, the article is very detailed, has a certain reference value, interested friends must read it!
6.0 middleware is divided into system middleware and application middleware. System middleware is the built-in middleware of the core framework, and application middleware is the middleware created in the application.
The main application scenarios of middleware can include data filtering, authority detection, request interception and other behaviors of HTTP requests. Using middleware can make the definition of the controller easier, and many additional non-core business processes can be handed over to the middleware for execution.
From the perspective of the scope of use of middleware, it can be divided into global middleware, application middleware, controller middleware and routing middleware.
Global middleware
Global middleware is defined in app\ middleware.php. No middleware is enabled by default, but the supported system middleware is annotated. You only need to uncomment to use the corresponding system middleware. The default content is as follows:
Return [/ / Global request cache / / 'think\ middleware\ CheckRequestCache', / / multilingual load / /' think\ middleware\ LoadLangPack', / / Session initialization / / 'think\ middleware\ SessionInit', / / Page Trace debugging / /' think\ middleware\ TraceDebug',]
Some functions of the system are handed over to the middleware for unified management, including global request caching, automatic multilingual detection and loading, Session initialization and page Trace debugging. In other words, the installed application does not support Session by default, and you must enable the Session initialization middleware globally before Session can take effect. For API applications, there is no need for Session function support.
You can add your application middleware to the global middleware definition file, but make sure that the system middleware is executed first as much as possible. The middleware definition needs to use a complete class name, and you can quickly create an application middleware through command-line instructions:
Php think make:middleware Test
An app\ middleware\ Test middleware class is automatically generated as follows:
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.