PHPackages                             ez-php/http - 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. ez-php/http

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

ez-php/http
===========

HTTP message objects for the ez-php framework — immutable Request, Response, RequestFactory, and ResponseEmitter. Zero dependencies.

1.11.1(1mo ago)04.6k↓90%13MITPHPPHP ^8.5CI passing

Since Mar 14Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/http)[ Packagist](https://packagist.org/packages/ez-php/http)[ Docs](https://github.com/ez-php/http)[ RSS](/packages/ez-php-http/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (14)Versions (48)Used By (13)

ez-php/http
===========

[](#ez-phphttp)

HTTP message objects for PHP — immutable `Request`, `Response`, `RequestFactory`, `ResponseFactory`, `ResponseEmitter`, `Cookie`, and `UploadedFile`. Zero dependencies.

[![CI](https://github.com/ez-php/http/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-php/http/actions/workflows/ci.yml)

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

[](#requirements)

- PHP 8.5+

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

[](#installation)

```
composer require ez-php/http
```

Usage
-----

[](#usage)

### Request

[](#request)

```
use EzPhp\Http\Request;
use EzPhp\Http\RequestFactory;

// Create from PHP globals (web context)
$request = RequestFactory::createFromGlobals();

echo $request->method();           // GET, POST, ...
echo $request->uri();              // /users/42
echo $request->query('page');      // query string value
echo $request->input('name');      // POST body value
echo $request->header('accept');   // request header (case-insensitive)
echo $request->cookie('session');  // cookie value
echo $request->param('id');        // route parameter (set by router)
echo $request->rawBody();          // raw request body string
echo $request->ip();               // client IP (X-Forwarded-For aware)

// Uploaded files
$file = $request->file('avatar');  // returns UploadedFile|null

// Immutable — returns a new instance
$request = $request->withMethod('PATCH');
$request = $request->withParams(['id' => '42']);
```

### Response

[](#response)

```
use EzPhp\Http\Response;
use EzPhp\Http\ResponseEmitter;
use EzPhp\Http\ResponseFactory;

$response = new Response(body: 'Hello', status: 200);

// Fluent header chaining — each call returns a new instance
$response = $response
    ->withHeader('Content-Type', 'application/json')
    ->withHeader('X-Request-Id', 'abc123');

// Factory helpers
$json     = ResponseFactory::json(['id' => 1]);
$redirect = ResponseFactory::redirect('/dashboard');
$html     = ResponseFactory::html('Hello');

// Send to the browser
(new ResponseEmitter())->emit($response);
```

### Cookie

[](#cookie)

```
use EzPhp\Http\Cookie;

$cookie = new Cookie(
    name:     'session',
    value:    'abc123',
    expires:  time() + 3600,
    path:     '/',
    secure:   true,
    httpOnly: true,
    sameSite: 'Lax',
);

$response = $response->withHeader('Set-Cookie', $cookie->toHeaderValue());
```

### UploadedFile

[](#uploadedfile)

```
use EzPhp\Http\UploadedFile;

$file = $request->file('avatar'); // returns UploadedFile|null

if ($file !== null && $file->isValid()) {
    $file->moveTo('/var/www/uploads/' . $file->clientFilename());
    echo $file->clientMimeType(); // 'image/jpeg'
    echo $file->size();           // bytes
}
```

Classes
-------

[](#classes)

ClassDescription`RequestInterface`Contract for the `Request` value object`Request`Immutable HTTP request value object (`final readonly class`)`RequestFactory`Builds a `Request` from PHP superglobals`Response`HTTP response value object; clone-based `withHeader()``ResponseFactory`Static helpers: `json()`, `redirect()`, `html()`, `text()`, `noContent()``ResponseEmitter`Sends a `Response` to the client via `http_response_code()` and `header()``HeaderSenderInterface`Abstraction over `header()` calls (injectable for testing)`NativeHeaderSender`Default `HeaderSenderInterface` implementation using PHP's `header()``Cookie`Immutable value object for `Set-Cookie` attributes; `toHeaderValue()` produces the header string`UploadedFile`Wraps a `$_FILES` entry; `isValid()`, `moveTo()`, `clientFilename()`, `clientMimeType()`, `size()`License
-------

[](#license)

MIT — [Andreas Uretschnig](mailto:andreas.uretschnig@gmail.com)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance91

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 90.6% 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 ~1 days

Total

47

Last Release

44d ago

Major Versions

0.9.3 → 1.0.02026-03-25

### Community

Maintainers

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

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (116 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")

---

Tags

httpresponserequestpsrphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ez-php-http/health.svg)

```
[![Health](https://phpackages.com/badges/ez-php-http/health.svg)](https://phpackages.com/packages/ez-php-http)
```

###  Alternatives

[fig/http-message-util

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

39394.6M297](/packages/fig-http-message-util)[psr/http-server-middleware

Common interface for HTTP server-side middleware

18399.3M1.8k](/packages/psr-http-server-middleware)

PHPackages © 2026

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