PHP code example of touhidurabir / laravel-request-response-logger

1. Go to this page and download the library: Download touhidurabir/laravel-request-response-logger 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/ */

    

touhidurabir / laravel-request-response-logger example snippets


protected $routeMiddleware = [
    ...
    'requests.responses.logger' => \Touhidurabir\RequestResponseLogger\Middlewares\LogRequestResponse::class,
];

// And then use it for one or more routes
Route::any('/some-route', SomeController::class)->middleware(['requests.responses.logger']);

protected $middlewareGroups = [
    ...
    'api' => [
        \Touhidurabir\RequestResponseLogger\Middlewares\LogRequestResponse::class,
    ],
];

protected $middleware = [
    ...
    \Touhidurabir\RequestResponseLogger\Middlewares\LogRequestResponse::class,
];

protected function schedule(Schedule $schedule) {
    ...
    $schedule->command('request-response-logger:clear')->weekly();
}

protected function schedule(Schedule $schedule) {
    ...
    $schedule->command('request-response-logger:export')->dailyAt('00:01');
}

protected function schedule(Schedule $schedule) {
    ...
    $schedule->command('request-response-logger:redis-import')->hourly();
}

use Touhidurabir\RequestResponseLogger\Models\RequestResponseLogger;

// Get every logged item with an http response code of 2xx:
RequestResponseLogger::successful()->get();

// Get every logged item with an http response code that ISN'T 2xx:
RequestResponseLogger::failed()->get();

// Get every logged item which are marked
RequestResponseLogger::marked()->get();

RequestResponseLogger::with(['user'])->get();
bash
php artisan vendor:publish --provider="Touhidurabir\RequestResponseLogger\RequestResponseLoggerServiceProvider"
bash
php artisan migrate
bash
php artisan request-response-logger:clear
bash
php artisan request-response-logger:export