There is a terminate method as well :)
https://laravel.com/docs/11.x/middleware#terminable-middleware
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I created a middleware and registered it in Kernel.app => API to save a log whenever the API routes are used, as I need to monitor some behaviors.
I am able to monitor all requests correctly using $_SERVER['REQUEST_URI'], but I also need to record the time it took for this route to return, thus understanding the performance of the endpoints. Currently, I use the handle() function of the middleware that is executed at the beginning of the request.
Can you tell me any way I can get this request time to save in the log?
Thanks
There is a terminate method as well :)
https://laravel.com/docs/11.x/middleware#terminable-middleware
Please or to participate in this conversation.