PHPackages                             tourze/psr15-chain-request-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. tourze/psr15-chain-request-handler

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

tourze/psr15-chain-request-handler
==================================

PSR-15 Chain Request Handler

0.0.2(1y ago)0179↓93.3%2MITPHPPHP ^8.1CI passing

Since Apr 24Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/tourze/psr15-chain-request-handler)[ Packagist](https://packagist.org/packages/tourze/psr15-chain-request-handler)[ RSS](/packages/tourze-psr15-chain-request-handler/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (5)Versions (3)Used By (2)

psr15-chain-request-handler
===========================

[](#psr15-chain-request-handler)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/0c2f2fc302d58f5a4f74f9319f371ebfc33dc4032f4d225976568818c90acb89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f70737231352d636861696e2d726571756573742d68616e646c65722e737667)](https://packagist.org/packages/tourze/psr15-chain-request-handler)[![Build Status](https://github.com/tourze/php-monorepo/actions/workflows/ci.yml/badge.svg)](https://github.com/tourze/php-monorepo/actions)[![Coverage Status](https://camo.githubusercontent.com/7b64a7279d6174545ed88c7d8849424707939555a7856f322f685b0f6543b1f6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f2f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/tourze/php-monorepo?branch=main)[![License](https://camo.githubusercontent.com/fba0da37aa178cb1819325b283b6e122da2e71a54e7425b55395713b74510b1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f70737231352d636861696e2d726571756573742d68616e646c65722e737667)](https://packagist.org/packages/tourze/psr15-chain-request-handler)

Introduction
------------

[](#introduction)

A PSR-15 compatible chain request handler for PHP. This package allows you to combine multiple request handlers in a chain, processing HTTP requests sequentially until a handler returns a non-404 response. If all handlers return 404, a final 404 response is returned.

Features
--------

[](#features)

- Chain multiple PSR-15 request handlers
- Automatically skips handlers that return 404
- Simple API for adding handlers dynamically
- Fully PSR-15 compatible
- Well-tested and easy to integrate

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

[](#installation)

Requirements:

- PHP &gt;= 8.1
- psr/http-message ^1.1|^2.0
- psr/http-server-handler ^1.0
- nyholm/psr7 ^1.8.2

Install via Composer:

```
composer require tourze/psr15-chain-request-handler
```

Quick Start
-----------

[](#quick-start)

```
use Nyholm\Psr7\ServerRequest;
use Nyholm\Psr7\Response;
use Tourze\PSR15ChainRequestHandler\ChainRequestHandler;
use Psr\Http\Server\RequestHandlerInterface;

// Example handler that always returns 404
class NotFoundHandler implements RequestHandlerInterface {
    public function handle($request): Response {
        return new Response(404, body: 'Not Found');
    }
}

// Example handler that returns 200 for a specific path
class HelloHandler implements RequestHandlerInterface {
    public function handle($request): Response {
        if ($request->getUri()->getPath() === '/hello') {
            return new Response(200, body: 'Hello World');
        }
        return new Response(404, body: 'Not Found');
    }
}

$chain = new ChainRequestHandler([
    new NotFoundHandler(),
    new HelloHandler(),
]);

$request = new ServerRequest('GET', '/hello');
$response = $chain->handle($request);
// $response->getStatusCode() === 200
```

Documentation
-------------

[](#documentation)

- [API Reference](src/ChainRequestHandler.php)
- See `tests/ChainRequestHandlerTest.php` for usage scenarios

Advanced Usage
--------------

[](#advanced-usage)

- Add handlers dynamically with `$chain->addHandler($handler);`
- Handlers are processed in the order they are added
- If no handler returns a non-404 response, the chain returns a 404 with body 'Not Found'

Contributing
------------

[](#contributing)

- Please submit issues or pull requests via GitHub
- Follow PSR coding standards
- Run tests with PHPUnit before submitting PRs

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Changelog
---------

[](#changelog)

See the [CHANGELOG](../../CHANGELOG.md) for release history and upgrade notes.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance53

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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

2

Last Release

434d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13899502?v=4)[tourze](/maintainers/tourze)[@tourze](https://github.com/tourze)

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-psr15-chain-request-handler/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-psr15-chain-request-handler/health.svg)](https://phpackages.com/packages/tourze-psr15-chain-request-handler)
```

###  Alternatives

[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M67](/packages/bref-bref)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.6k10](/packages/sunrise-http-router)[sproutcms/cms

Enterprise content management and framework

242.5k4](/packages/sproutcms-cms)

PHPackages © 2026

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