Published under Laravel.
Here's a quick snippet to get HTTP request logging setup quickly in Laravel:
Because both the
terminate methods access the
$this->startTime variable, we need to make sure we receive the same instance of the middleware in both methods. To do this, you need to register the middleware as a singleton in the
boot method of your
Don't forget to add the middleware to the
$middleware array in
Credit to https://github.com/spatie/laravel-http-logger for some of the lines.