PHPackages                             district5/minimum-version - 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. district5/minimum-version

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

district5/minimum-version
=========================

A minimum version enforcement library, with adapters in place for the Slim Framework 4 and PSR-7 libraries.

1.0.2(11mo ago)055↓100%mitPHPPHP &gt;=8.1CI passing

Since May 19Pushed 11mo agoCompare

[ Source](https://github.com/district-5/minimum-version)[ Packagist](https://packagist.org/packages/district5/minimum-version)[ Docs](https://github.com/district-5/minimum-version)[ RSS](/packages/district5-minimum-version/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

[![CI](https://github.com/district-5/minimum-version/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/district-5/minimum-version/actions)[![Latest Stable Version](https://camo.githubusercontent.com/f3cd00e6ae98a38977494f2e80eff24880ad700bdc81bf17910cab01a6e0a641/687474703a2f2f706f7365722e707567782e6f72672f6469737472696374352f6d696e696d756d2d76657273696f6e2f76)](https://packagist.org/packages/district5/minimum-version)[![PHP Version Require](https://camo.githubusercontent.com/4563e8c3df5343edc8fc70d645aa5e29a8538f714d390e1d6db28f7b5a21ba08/687474703a2f2f706f7365722e707567782e6f72672f6469737472696374352f6d696e696d756d2d76657273696f6e2f726571756972652f706870)](https://packagist.org/packages/district5/minimum-version)[![Codecov](https://camo.githubusercontent.com/bac4d1b3c0e4f3f2f34c1b5a1a6b4efbab75a046913e85d58f8c72b6e9e5b3f2/68747470733a2f2f636f6465636f762e696f2f67682f64697374726963742d352f6d696e696d756d2d76657273696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/district-5/minimum-version)

Minimum version enforcement for API services...
===============================================

[](#minimum-version-enforcement-for-api-services)

### Slim Framework 4 usage

[](#slim-framework-4-usage)

See the official [Slim Framework 4](https://www.slimframework.com/docs/v4/objects/routing.html#route-middleware)middleware documentation for more information.

When using the Slim Framework 4, you can use the `Slim4Middleware` class to enforce a minimum version for your API.

If a request is made with a version lower than the minimum version, a native Slim HttpException, of code `406` will be thrown. A `406` means "Not Acceptable", which is the correct response code for this situation.

There are two methods of constructing the middleware:

#### Option 1, using static values

[](#option-1-using-static-values)

```
use District5\MinimumVersion\Slim\Slim4Middleware;
use District5\MinimumVersion\Slim\Slim4Checker;

$app->add(
    new Slim4Middleware(
        Slim4Checker::fromValues(
            '1.0.0', // Minimum version to accept
            ['0.9.9', '1.0.0'], // Explicitly allowed versions
            'X-Api-Version' // Header name to check version against, defaults to 'X-Version'
        )
    )
);
```

#### Option 2, using environment variables

[](#option-2-using-environment-variables)

```
use District5\MinimumVersion\Slim\Slim4Middleware;
use District5\MinimumVersion\Slim\Slim4Checker;

$app->add(
    new Slim4Middleware(
        Slim4Checker::fromEnv(
            'MINIMUM_VERSION', // Environment variable name for minimum version, e.g. '1.0.0'
            'ALLOWED_VERSIONS', // Environment variable name for allowed versions, comma-separated, e.g. '0.0.9, 1.0.0'
            Slim4Middleware::VERSION_HEADER // This is the default value of 'X-Version'. The header name to check version
        )
    )
);
```

### Install with composer...

[](#install-with-composer)

```
composer require district5/minimum-version

```

### Testing...

[](#testing)

```
composer install
./vendor/bin/phpunit

```

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance54

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

3

Last Release

354d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5de4b9a90eadf6b595e1b5efc802683f2358da5661c616820b90c922f8aa8e05?d=identicon)[rogerthomas84](/maintainers/rogerthomas84)

![](https://www.gravatar.com/avatar/c566343bfe6b0a3602622dd1def882992f10ff114b6a95ffb000da2ba9e22578?d=identicon)[mark-morgan](/maintainers/mark-morgan)

---

Top Contributors

[![rogerthomas84](https://avatars.githubusercontent.com/u/350232?v=4)](https://github.com/rogerthomas84 "rogerthomas84 (7 commits)")

---

Tags

requestpsr-7slimEnforcementminimum version

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/district5-minimum-version/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.0B3.1k](/packages/guzzlehttp-psr7)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k692.9M1.9k](/packages/psr-http-factory)[psr/http-server-handler

Common interface for HTTP server-side request handler

175101.3M918](/packages/psr-http-server-handler)[psr/http-server-middleware

Common interface for HTTP server-side middleware

18091.2M1.5k](/packages/psr-http-server-middleware)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[jasny/auth

Authentication, authorization and access control for Slim Framework and other PHP micro-frameworks

11816.4k1](/packages/jasny-auth)

PHPackages © 2026

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