PHP code example of dniccum / laravel-request-logs

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

    

dniccum / laravel-request-logs example snippets


return [

    /*
    |--------------------------------------------------------------------------
    | Table Name
    |--------------------------------------------------------------------------
    |
    | The name of the table that will store the log entries.
    |
    */

    'table_name' => 'request_logs',

    /*
    |--------------------------------------------------------------------------
    | History
    |--------------------------------------------------------------------------
    |
    | The number of days of logs that you would like to keep in the database
    | at any time.
    |
    */

    'history' => env('LOGGING_HISTORY', 21),

    /*
    |--------------------------------------------------------------------------
    | Remove Bearer Token
    |--------------------------------------------------------------------------
    |
    | Enable if you would like to remove the bearer authentication token from
    | the request header.
    |
    */

    'remove_bearer' => env('LOGGING_REMOVE_BEARER', true),

];

protected $middlewareGroups = [
        'web' => [
            ...
        ],

        'api' => [
            ...
            \Dniccum\LaravelRequestLogs\Http\Middleware\RequestLogging::class,
        ],
    ];

/**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        ...
        'route-logging' => \Dniccum\LaravelRequestLogs\Http\Middleware\RequestLogging::class
    ];

Route::post('/create-project', [ \App\Http\Controllers\SampleController::class, 'create' ])
    ->middleware([ 'route-logging' ]);

$schedule->job(\Dniccum\LaravelRequestLogs\Commands\CleanReqeustLogsCommand::class)
    ->daily();
bash
php artisan vendor:publish --tag="laravel-request-logs-migrations"
php artisan migrate --force
bash
php artisan vendor:publish --tag="laravel-request-logs-config"