Here's a way to encode a Laravel site request as JSON to log it via Laravel's logging mechanism, using the Log
class from the illuminate/support
package1.
// Log parameters in a get request
Route::get('a-view', function(Request $request) {
\Log::info(json_encode(request()->server()));
return view('your.view');
});
// Log parameters in a get request and redirect
Route::get('redirect', function(Request $request) {
\Log::info(json_encode(request()->server()));
return redirect('/some/page');
});
The service provider of Laravel's Log
class is Illuminate\Support\Facades\Log
. ↩