2017 © Pedro PelĂĄez
 

library correlate-php-psr-7

PSR-7 middleware to handle incoming correlation id header for microservices.

image

proemergotech/correlate-php-psr-7

PSR-7 middleware to handle incoming correlation id header for microservices.

  • Wednesday, September 13, 2017
  • by shakahl
  • Repository
  • 2 Watchers
  • 0 Stars
  • 366 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

correlate-php-psr-7


Overview

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

Packages

Installation

  • Install via composer
composer require proemergotech/correlate-php-psr-7

Setup for Slim 3 framework

To use this class as a middleware, you can use ->add( new ExampleMiddleware() ); function chain after the $app, Route, or group(), which in the code below, any one of these, could represent $subject., (*2)

$logger = $app['monolog']; // Must be \Monolog\Logger

// This is an optional callback function to set correlation id to a DIC.
$callback = function($correlationId) use ($app) { 
    $app->getContainer()['cid'] = $correlationId;
}

$subject->add(new \ProEmergotech\Correlate\Psr7\Psr7CorrelateMiddleware($logger, $callback));

Passing \Monolog\Logger is optional., (*3)

Usage

This middleware automatically adds correlation id (coming from request header) to every log messages if you provided the optional \Monolog\Logger instance to middleware's constructor., (*4)

You can access the correlation id IN A ROUTE CONTROLLER if you want to work with it., (*5)

$cid = $request->getAttribute(\ProEmergotech\Correlate\Correlate::getParamName());

Contributing

See CONTRIBUTING.md file., (*6)

Credits

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

License

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

The Versions

13/09 2017

dev-master

9999999-dev https://github.com/proemergotech/correlate-php-psr-7

PSR-7 middleware to handle incoming correlation id header for microservices.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel psr-7 log microservice lumen uuid dispatcher slim correlate