PHP code example of aymanalhattami / log-request-response
1. Go to this page and download the library: Download aymanalhattami/log-request-response library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aymanalhattami / log-request-response example snippets
use Illuminate\Support\Facades\Route;
use AymanAlhattami\LogRequestResponse\Http\Middleware\LogRequestResponseMiddleware;
use App\Http\Controllers\ExampleController;
# Log all routes
Route::middleware(LogRequestResponseMiddleware::class)->group(function() {
// routes
});
# Log single route
Route::get('example', ExampleController::class)->middleware(LogRequestResponseMiddleware::class);
use Illuminate\Support\Facades\Route;
use AymanAlhattami\LogRequestResponse\Http\Middleware\LogRequestMiddleware;
use App\Http\Controllers\ExampleController;
# Log all routes
Route::middleware(LogRequestMiddleware::class)->group(function() {
// routes
});
# Log single route
Route::get('example', ExampleController::class)->middleware(LogRequestMiddleware::class);
use Illuminate\Support\Facades\Route;
use AymanAlhattami\LogRequestResponse\Http\Middleware\LogResponseMiddleware;
use App\Http\Controllers\ExampleController;
# Log all routes
Route::middleware(LogResponseMiddleware::class)->group(function() {
// routes
});
# Log single route
Route::get('example', ExampleController::class)->middleware(LogResponseMiddleware::class);
use Illuminate\Support\Facades\Route;
use AymanAlhattami\LogRequestResponse\Http\Middleware\LogHeadersMiddleware;
use App\Http\Controllers\ExampleController;
# Log all routes
Route::middleware(LogHeadersMiddleware::class)->group(function() {
// routes
});
# Log single route
Route::get('example', ExampleController::class)->middleware(LogHeadersMiddleware::class);
return [
/* Defines the logging level for recording request and response logs. Default: 'info'. */
'log_level' => env('REQUEST_RESPONSE_LOG_LEVEL', 'info'),
'request' => [
/* Determines whether logging of HTTP requests is enabled. */
'enabled' => env('LOG_REQUEST', true),
/* Title or prefix for request logs, making them easily identifiable. */
'title' => env('LOG_REQUEST_TITLE', 'Request'),
/* Specifies whether headers should be d user should be if both 'only' and 'except' are not empty, then only the data specified in 'only' will be logged.
* if 'only' is empty, but 'except' is not empty, then all data except the data specified in 'except' will be logged.
* if 'only' is not empty, but 'except' is empty, then only the data specified in 'only' will be logged.
*/
'data' => [
'only' => [],
'except' => ['password', 'password_confirmation'],
],
/**
* Specifying which URLs should be logged.
* if 'only' has data, then 'except' will be ignored.
* if 'except' has data, then 'only' will be ignored.
* if both 'only' and 'except' are empty, then all URLs will be logged.
* if both 'only' and 'except' are not empty, then only the URLs specified in 'only' will be logged.
* if 'only' is empty, but 'except' is not empty, then all URLs except the URLs specified in 'except' will be logged.
* if 'only' is not empty, but 'except' is empty, then only the URLs specified in 'only' will be logged.
*/
'urls' => [
'only' => [],
'except' => [],
]
],
'response' => [
/* Determines whether logging of HTTP responses is enabled. */
'enabled' => env('LOG_RESPONSE', true),
/* Title or prefix for response logs. */
'title' => env('LOG_RESPONSE_TITLE', 'Response'),
/* Indicates whether information about the authenticated user should be
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.