Middleware to generate an UUID and save it in the X-Uuid header

v1.1.0 2018-08-04 10:41 UTC


Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabs Insight

Middleware to generate an UUID (Universally Unique Identifiers) and save it in the X-Uuid header of the request and response. Useful for debugging purposes.

The UUID generated is compatible with RFC 4122 version 4 using ramsey/uuid for that.



This package is installable and autoloadable via Composer as middlewares/uuid.

composer require middlewares/uuid


$dispatcher = new Dispatcher([
	new Middlewares\Uuid(),

    function ($request) {
        //Get the UUID from the request
        echo $request->getHeaderLine('X-Uuid');

$response = $dispatcher->dispatch(new ServerRequest());

//Get the UUID from the response
echo $response->getHeaderLine('X-Uuid');


header(string $header)

To configure the header name. By default is X-Uuid.

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.