How does laravel use Middleware to record user request Log
This article mainly explains "how laravel uses middleware to record user request log". The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "laravel how to use middleware to record user request log".
First, create middleware
You can create it using the command or directly
Php artisan make:middleware Middleware name (TraceRecordMiddleware) II. Registration Middleware
Because different versions of laravel have different ways to register the median price, take version 5.6 as an example.
Just add the following code directly to the project bootstarp/app.php
$app- > middleware ([App\ Http\ Middleware\ TraceRecordMiddleware::class]); third, record user access log
In fact, the median price can be understood as a request interceptor.
Therefore, the data before the user's request and the response data after the user's request can be intercepted.
The following are based on the intermediate price template