PHPackages                             ahmard/reaponse - 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. ahmard/reaponse

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

ahmard/reaponse
===============

ReactPHP response helper

1.0.1(5y ago)312MITPHPPHP ^7.4 || ^8.0

Since Feb 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Ahmard/reaponse)[ Packagist](https://packagist.org/packages/ahmard/reaponse)[ RSS](/packages/ahmard-reaponse/feed)WikiDiscussions master Synced yesterday

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

ReactPHP Response Helper
========================

[](#reactphp-response-helper)

This library provides beautiful syntax for [ReactPHP HTTP](https://reactphp.org/http)component, this library provides syntax very similar to that of NodeJS.

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

[](#installation)

You will need [Composer](https://getcomposer.org) to install this library.

```
composer require ahmard/reactphp-response
```

Usage
-----

[](#usage)

### Registering middleware

[](#registering-middleware)

- Test\\Counter

```
namespace Test;

use Reaponse\Http\HandlerInterface;
use Reaponse\Http\ResponseInterface;

class CountHandler implements HandlerInterface
{
    protected static int $counts = 0;

    public function handle(ResponseInterface $response): void
    {
        self::$counts++;
        $response->write('Count: ' . self::$counts);
        $response->handler()->next();
    }
}
```

- Test\\Server

```
namespace Test;

use Reaponse\Http\HandlerInterface;
use Reaponse\Http\ResponseInterface;

class ServerHandler implements HandlerInterface
{
    public function handle(ResponseInterface $response): void
    {
        $response->html(', Time: ' . date('H:i:s'));
        $response->end('.');
    }
}
```

- server.php

```
use React\EventLoop\Factory;
use React\Socket\Server;
use Reaponse\Http\Middleware;
use Test\CounterHandler;
use Test\ServerHandler;

require 'vendor/autoload.php';

$loop = Factory::create();
$uri = '0.0.0.0:9200';

$myServer = new ServerHandler();
$myCounter = new CounterHandler();

$httpServer = new \React\Http\Server($loop, new Middleware($myCounter, $myServer));
$socketServer = new Server($uri, $loop);

$httpServer->listen($socketServer);
$httpServer->on('error', function (Throwable $throwable){
    echo $throwable;
});

echo "Server started at http://{$uri}\n";
$loop->run();
```

Start the server

```
php server.php
```

### Request object

[](#request-object)

```
use Reaponse\Http\HandlerInterface;
use Reaponse\Http\ResponseInterface;

class TestHandler implements HandlerInterface
{
    public function handle(ResponseInterface $response): void
    {
        //psr-7 compliant object
        $request = $response->request();

        $response->html("Method: {$request->getMethod()}");

        $response->end('Bye!');
    }
}
```

### Listens to response events

[](#listens-to-response-events)

```
use Reaponse\Http\HandlerInterface;
use Reaponse\Http\Response;
use Reaponse\Http\ResponseInterface;

class TestHandler implements HandlerInterface
{
    public function handle(ResponseInterface $response): void
    {
        //listens to write event
        $response->on(Response::ON_WRITE, function (){
            echo "Writing...\n";
        });
        //Listens to headers event
        $response->on(Response::ON_HEADERS, function (){
            echo "Headers...\n";
        });
        //Listens to next handler event
        $response->on(Response::ON_NEXT_HANDLER, function (){
            echo "Next handler...\n";
        });
        //Listens to response sending event
        $response->on(Response::ON_BEFORE_SEND, function (){
            echo "Sending...\n";
        });

        $response->end('Hello World');
    }
}
```

- All handlers must implement [HandlerInterface](src/Http/HandlerInterface.php)
- A handler is a middleware, handler is just a fancy name given to it.

### [Example](example)

[](#example)

Licence
-------

[](#licence)

**Reaponse** is **MIT** licenced.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

1921d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b69fe34bd6492697a19cd8f33bde7a381cab0b7f8c0a01dcc7505f482458887?d=identicon)[Ahmard](/maintainers/Ahmard)

---

Top Contributors

[![Ahmard](https://avatars.githubusercontent.com/u/44737217?v=4)](https://github.com/Ahmard "Ahmard (3 commits)")

---

Tags

phpreactphpreactphp-componentsreaponsehttpresponsereactphpSocket

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ahmard-reaponse/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

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

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-factory

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

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

🌐 Nette Http: abstraction for HTTP request, response and session. Provides careful data sanitization and utility for URL and cookies manipulation.

48619.2M541](/packages/nette-http)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)[fig/http-message-util

Utility classes and constants for use with PSR-7 (psr/http-message)

39489.0M274](/packages/fig-http-message-util)

PHPackages © 2026

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