PHPackages                             middlewares/uuid - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. middlewares/uuid

ActiveLibrary[HTTP &amp; Networking](/categories/http)

middlewares/uuid
================

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

v2.1.0(1y ago)421.7k—5.6%[1 issues](https://github.com/middlewares/uuid/issues)3MITPHPPHP ^7.2 || ^8.0CI passing

Since Oct 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/middlewares/uuid)[ Packagist](https://packagist.org/packages/middlewares/uuid)[ Docs](https://github.com/middlewares/uuid)[ RSS](/packages/middlewares-uuid/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (12)Used By (3)

middlewares/uuid
================

[](#middlewaresuuid)

[![Latest Version on Packagist](https://camo.githubusercontent.com/345cf31995da6f640543cd81edfb7ea1881806b5312fcbce5302e2cbca9e8dca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6964646c6577617265732f757569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/middlewares/uuid)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Testing](https://github.com/middlewares/uuid/workflows/testing/badge.svg)](https://github.com/middlewares/uuid/workflows/testing/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/8eb03a0373a3f14a025d3e67af4057719dc872f616dc11bb9cca1c73c226e69f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6964646c6577617265732f757569642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/middlewares/uuid)

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](http://tools.ietf.org/html/rfc4122) version 4 using [ramsey/uuid](https://github.com/ramsey/uuid) for that.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2
- A [PSR-7 http library](https://github.com/middlewares/awesome-psr15-middlewares#psr-7-implementations)
- A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)

Installation
------------

[](#installation)

This package is installable and autoloadable via Composer as [middlewares/uuid](https://packagist.org/packages/middlewares/uuid).

```
composer require middlewares/uuid
```

Usage
-----

[](#usage)

```
Dispatcher::run([
	new Middlewares\Uuid(),

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

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

### header

[](#header)

This option allows to configure the header name. By default is `X-Uuid`.

```
$uuid = (new Middlewares\Uuid())->header('X-Request-Id');
```

---

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details.

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

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance41

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~309 days

Recently: every ~652 days

Total

11

Last Release

421d ago

Major Versions

v0.6.0 → v1.0.02018-01-27

v1.1.0 → v2.0.02020-12-03

PHP version history (3 changes)v0.1.0PHP ^5.6 || ^7.0

v0.6.0PHP ^7.0

v2.0.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e99df56b617f4af8cf0556a51a0ca20c7420104920c57d7e9eab093f92bb744f?d=identicon)[oscarotero](/maintainers/oscarotero)

![](https://www.gravatar.com/avatar/42e0d72f42eb7d84f67e20d28606da42e5a3248ca908b1eadb4366aafeae2561?d=identicon)[filisko](/maintainers/filisko)

---

Top Contributors

[![oscarotero](https://avatars.githubusercontent.com/u/377873?v=4)](https://github.com/oscarotero "oscarotero (48 commits)")[![filisko](https://avatars.githubusercontent.com/u/8798694?v=4)](https://github.com/filisko "filisko (2 commits)")[![flavioheleno](https://avatars.githubusercontent.com/u/471860?v=4)](https://github.com/flavioheleno "flavioheleno (1 commits)")

---

Tags

httpmiddlewarepsr-15uuidhttppsr-7middlewareuuidpsr-15

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/middlewares-uuid/health.svg)

```
[![Health](https://phpackages.com/badges/middlewares-uuid/health.svg)](https://phpackages.com/packages/middlewares-uuid)
```

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[laminas/laminas-stratigility

PSR-7 middleware foundation for building and dispatching middleware pipelines

586.6M81](/packages/laminas-laminas-stratigility)[middlewares/utils

Common utils for PSR-15 middleware packages

503.4M92](/packages/middlewares-utils)[middlewares/request-handler

Middleware to execute request handlers

451.6M26](/packages/middlewares-request-handler)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[middlewares/fast-route

Middleware to use FastRoute

96191.1k15](/packages/middlewares-fast-route)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
