PHPackages                             sheridan/version-middleware - 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. sheridan/version-middleware

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

sheridan/version-middleware
===========================

PSR-7 middleware for managing routable versioning.

v2.0.0(2mo ago)055BSD-3-ClausePHPPHP ^8.2CI failing

Since Mar 18Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/sheridans/psr7-version-middleware)[ Packagist](https://packagist.org/packages/sheridan/version-middleware)[ RSS](/packages/sheridan-version-middleware/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

version-middleware
==================

[](#version-middleware)

PSR-15 middleware that extracts API version prefixes from the URL path. Works with any PSR-15 framework (Mezzio, Slim, etc.).

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

[](#installation)

Install using composer:

```
$ composer require sheridan/version-middleware

```

Usage
-----

[](#usage)

### Add to pipeline

[](#add-to-pipeline)

```
use Psr7Versioning\VersionMiddleware;
...
$app->pipe(ServerMiddleware::class);
$app->pipe(VersionMiddleware::class);
$app->pipe(RouteMiddleware::class);
...

```

Routing
-------

[](#routing)

Now you can add route based on path, for example:

```
$app->get('/home', 'Handler\HomePageHandler::class', 'home');
$app->get('/dev/home', 'Handler\dev\HomePageHandler::class', 'home.dev');
$app->get('/latest/home', 'Handler\latest\HomePageHandler::class', 'home.latest');
$app->get('/legacy/home', 'Handler\legacy\HomePageHandler::class', 'home.legacy');
$app->get('/v1/home', 'Handler\v1\HomePageHandler::class', 'home.v1');
$app->get('/v2/home', 'Handler\v2\HomePageHandler::class', 'home.v2');

```

Built in version routes are

- dev
- latest
- legacy
- vnnn (where nnn is a number)

To get the version number from a request:

```
use Psr7Versioning\VersionMiddleware;
...
public function handle (ServerRequest $request) : ResponseInterface
{
  // get current version (ie dev | latest)
  $version = $request->getAttribute(VersionMiddleware::class);
}

```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance87

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

62d ago

### Community

Maintainers

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

---

Top Contributors

[![sheridans](https://avatars.githubusercontent.com/u/9597981?v=4)](https://github.com/sheridans "sheridans (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

psr-7phpmiddlewareapilaminaspsr7versioningmezzio

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sheridan-version-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/sheridan-version-middleware/health.svg)](https://phpackages.com/packages/sheridan-version-middleware)
```

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.0M61](/packages/mezzio-mezzio-router)[mezzio/mezzio-helpers

Helper/Utility classes for Mezzio

134.3M67](/packages/mezzio-mezzio-helpers)[mezzio/mezzio-fastroute

FastRoute integration for Mezzio

162.7M52](/packages/mezzio-mezzio-fastroute)

PHPackages © 2026

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