phauthentic/correlation-id

Correlation ID and PSR7 middleware to inject it

1.2.0 2021-10-03 11:17 UTC

This package is auto-updated.

Last update: 2022-10-01 00:09:22 UTC


README

Software License Scrutinizer Coverage Code Quality

A Correlation ID, also known as a Transit ID, is a unique identifier value that is attached to requests and messages that allow reference to a particular transaction or event chain. The Correlation Pattern, which depends on the use of Correlation ID is a well documented Enterprise Integration Pattern.

Documentation

Correlation ID

The correlation ID is a singleton class that will always return the same ID for the current life-cycle of the request.

Middleware

The middleware will automatically put the correlation ID into your request object as attribute and header value. By default both use the CorrelationID name.

$middleware = new CorrelationIDMiddleware(
    CorrelationID::toString()
);

Response

Since there is no standard for where this needs to be done, just add the correlation ID to your response where ever it suits your architecture or framework.

$response->withHeader('CorrelationID', CorrelationId::toString());

Copyright & License

Licensed under the MIT license.

Copyright (c) Phauthentic / Florian Krämer