Looking to hire Laravel developers? Try LaraJobs

laravel-request-id maintained by alitindrawan24

Author
Last update
2024/05/18 17:57 (dev-main)
License
Links
Downloads
208

Comments
comments powered by Disqus

Laravel Request ID

Latest Version on Packagist Total Downloads License: MIT

Request ID is uniquely identifies the HTTP request sent from the app to the service and enables the app to correlate requests and responses, in case the app needs to resend a request because of a dropped connection. This package provides a middleware that allows to generate a unique request id and append on log context every time if the log called.

Installation

You can install the package via composer:

composer require alitindrawan24/laravel-request-id

You can publish the config file with:

php artisan vendor:publish --provider="Alitindrawan24\RequestID\RequestIDServiceProvider" --tag="config" 

Usage

This packages provides a middleware which can be added as a global middleware or as a single route.

// in `app/Http/Kernel.php`

protected $middleware = [
    // ...
    
    \Alitindrawan24\RequestID\Middleware\RequestIDMiddleware::class
];
// in a routes file

Route::post('/dashboard', function () {
    //
})->middleware(\Alitindrawan24\RequestID\Middleware\RequestIDMiddleware::class);

Testing

composer test

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Contributors