PHPackages                             kovagoz/http-middleware-closure-handler - 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. kovagoz/http-middleware-closure-handler

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

kovagoz/http-middleware-closure-handler
=======================================

PSR-15 compatible HTTP middleware which can utilize closure type request handlers.

1.1.2(3y ago)08MITPHPPHP ^8.0

Since Sep 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kovagoz/http-middleware-closure-handler)[ Packagist](https://packagist.org/packages/kovagoz/http-middleware-closure-handler)[ RSS](/packages/kovagoz-http-middleware-closure-handler/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

Closure Handler Middleware
==========================

[](#closure-handler-middleware)

PSR-15 compatible HTTP middleware which can utilize closure type request handlers.

If you don't want to bother about those ugly HTTP controllers and love simplicity, this middleware is your best friend.

[![phpunit workflow](https://github.com/kovagoz/http-middleware-closure-handler/actions/workflows/php.yml/badge.svg)](https://github.com/kovagoz/http-middleware-closure-handler/actions/workflows/php.yml/badge.svg)

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

[](#requirements)

- PHP &gt;=8.0

Usage
-----

[](#usage)

```
$request = $serverRequestFactory
    ->createServerRequest('GET', '/')
    ->withAttribute('__handler', fn() => 'hello world!');

$middleware = new ClosureHandler($responseFactory, $streamFactory);

$response = $middleware->process($request, $nextHandler);

echo $response->getBody(); // Will print "hello world!"
```

If no handler found in the request object, or handler is not closure, then the middleware passes the request to the next middleware in the row.

Name of the request attribute (`__handler`) can be changed by the `watchRequestAttribute()` method.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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 ~103 days

Total

4

Last Release

1379d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/664c17e6a7f99c063d1734e49da5623df8d9e91a30a692fcbb10bfc375eff43b?d=identicon)[kovagoz](/maintainers/kovagoz)

---

Tags

middlewarephppsr-15

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kovagoz-http-middleware-closure-handler/health.svg)

```
[![Health](https://phpackages.com/badges/kovagoz-http-middleware-closure-handler/health.svg)](https://phpackages.com/packages/kovagoz-http-middleware-closure-handler)
```

###  Alternatives

[league/openapi-psr7-validator

Validate PSR-7 messages against OpenAPI (3.0.2) specifications expressed in YAML or JSON

55615.9M69](/packages/league-openapi-psr7-validator)[league/route

Fast routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

6633.1M116](/packages/league-route)[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[relay/relay

A PSR-15 server request handler.

3302.1M84](/packages/relay-relay)[akrabat/ip-address-middleware

PSR-15 middleware that determines the client IP address and stores it as a ServerRequest attribute

1702.5M18](/packages/akrabat-ip-address-middleware)[laminas/laminas-stratigility

PSR-7 middleware foundation for building and dispatching middleware pipelines

586.6M81](/packages/laminas-laminas-stratigility)

PHPackages © 2026

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