2017 © Pedro PelĂĄez
 

library correlate-php-laravel

Middleware to handle incoming correlation id header for Laravel and Lumen

image

proemergotech/correlate-php-laravel

Middleware to handle incoming correlation id header for Laravel and Lumen

  • Friday, February 2, 2018
  • by shakahl
  • Repository
  • 2 Watchers
  • 1 Stars
  • 661 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

correlate-php-laravel


Overview

It's very difficult to track a request across the system when we are working with microservices. We came out with a solution for that. We generate a unique version 4 uuid for every request and every service passes this id via request headers to other services. We call this correlation ID., (*1)

Packages

Installation

  • Install via composer
composer require proemergotech/correlate-php-laravel

Setup for Laravel 5

Add the ProEmergotech\Correlate\Laravel\LaravelCorrelateMiddleware middleware to the $middleware property of your app/Http/Kernel.php class., (*2)

Setup for Lumen 5

Add service provider to bootstrap/app.php in your Lumen project., (*3)

// bootstrap/app.php

$app->register(\ProEmergotech\Correlate\Laravel\LaravelCorrelateServiceProvider::class);

Usage

This middleware automatically adds correlation id (coming from request header) to every log message. There are some macros added to the request object if you want to work with correlation id., (*4)

Using macros via request object:, (*5)

if ($request->hasCorrelationId()) {
  $cid = $request->getCorrelationId();
}
// or if you can change the ID
$request->setCorrelationId(\ProEmergotech\Correlate\Correlate::id());

Contributing

See CONTRIBUTING.md file., (*6)

Credits

This package was developed by Soma Szélpål at Pro Emergotech Ltd.., (*7)

Additional author is MiklĂłs Boros at Pro Emergotech Ltd.., (*8)

License

This project is released under the MIT License., (*9)

The Versions

02/02 2018