PHPackages                             waffle-commons/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. waffle-commons/http

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

waffle-commons/http
===================

Http component for Waffle framework.

0.1.0-alpha4(4mo ago)182[5 PRs](https://github.com/waffle-commons/http/pulls)1MITPHPPHP ^8.5CI passing

Since Nov 25Pushed 3mo agoCompare

[ Source](https://github.com/waffle-commons/http)[ Packagist](https://packagist.org/packages/waffle-commons/http)[ RSS](/packages/waffle-commons-http/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (13)Used By (1)

[![PHP Version Require](https://camo.githubusercontent.com/8d89b06d3e92fc0e052b666a2eb184ce8bf28ae40bf417a807b0eede13c02cab/687474703a2f2f706f7365722e707567782e6f72672f776166666c652d636f6d6d6f6e732f687474702f726571756972652f706870)](https://packagist.org/packages/waffle-commons/http)[![PHP CI](https://github.com/waffle-commons/http/actions/workflows/main.yml/badge.svg)](https://github.com/waffle-commons/http/actions/workflows/main.yml)[![codecov](https://camo.githubusercontent.com/3d5c45bb94576ae0b4a04b107ddf9b0410a6ab362a9c1a25c8388754db3fa43c/68747470733a2f2f636f6465636f762e696f2f67682f776166666c652d636f6d6d6f6e732f687474702f67726170682f62616467652e7376673f746f6b656e3d64373461633632612d373837322d343033352d386238622d626363336166313939316530)](https://codecov.io/gh/waffle-commons/http)[![Latest Stable Version](https://camo.githubusercontent.com/41e59cef379d6e47804809e6a42c552e5aa7c2378eab5e27d2666cd0b14c22af/687474703a2f2f706f7365722e707567782e6f72672f776166666c652d636f6d6d6f6e732f687474702f76)](https://packagist.org/packages/waffle-commons/http)[![Latest Unstable Version](https://camo.githubusercontent.com/6da9744a1b15237d9b7593cd32f4a1cf22dd7c210215bafa5138c793b805e643/687474703a2f2f706f7365722e707567782e6f72672f776166666c652d636f6d6d6f6e732f687474702f762f756e737461626c65)](https://packagist.org/packages/waffle-commons/http)[![Total Downloads](https://camo.githubusercontent.com/f05825789dbe4dada6c3a4597527cfd3f044ce619ce896ef9b91bed22ca26784/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776166666c652d636f6d6d6f6e732f687474702e737667)](https://packagist.org/packages/waffle-commons/http)[![Packagist License](https://camo.githubusercontent.com/7dc8fbf1d82a617703b9e2f72c1154c8aba5b6369b3e47885d005c16888775a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776166666c652d636f6d6d6f6e732f68747470)](https://github.com/waffle-commons/http/blob/main/LICENSE.md)

Waffle HTTP Component
=====================

[](#waffle-http-component)

A strict, lightweight, and high-performance implementation of PSR-7 (HTTP Message) and PSR-17 (HTTP Factories).

📦 Installation
--------------

[](#-installation)

```
composer require waffle-commons/http
```

🚀 Usage
-------

[](#-usage)

### 1. Creating a Request from Globals (Bootstrap)

[](#1-creating-a-request-from-globals-bootstrap)

The GlobalsFactory is designed to capture the current PHP environment (superglobals like `$_SERVER`, `$_POST`, `$_FILES`) and convert it into a PSR-7 ServerRequestInterface. This is typically used at the entry point of your application (index.php).

```
use Waffle\Commons\Http\Factory\GlobalsFactory;

// Create the factory
$factory = new GlobalsFactory();
// Capture the current request
$request = $factory->createFromGlobals();

echo $request->getMethod();
// e.g., "GET"  echo $request->getUri()->getPath();
// e.g., "/api/users"
```

### 2. Creating Responses

[](#2-creating-responses)

You can create responses manually or using the PSR-17 ResponseFactory.

**Manual Instantiation:**

```
use Waffle\Commons\Http\Response;

// Create a 200 OK response with JSON content
$response = new Response(
    200,
    ['Content-Type' => 'application/json'],
    json_encode(['status' => 'ok'])
);
```

**Using Factory (Recommended for decoupling):**

```
use Waffle\Commons\Http\Factory\ResponseFactory;

$factory = new ResponseFactory();
$response = $factory->createResponse(404, 'Resource Not Found');
```

### 3. Emitting a Response

[](#3-emitting-a-response)

To send the response to the client (browser), use the ResponseEmitter.

```
use Waffle\Commons\Http\Emitter\ResponseEmitter;

$emitter = new ResponseEmitter();
$emitter->emit($response);
```

### 4. Using PSR-17 Factories

[](#4-using-psr-17-factories)

This package provides implementations for all PSR-17 factory interfaces, allowing you to create HTTP objects in a standard way.

- **Waffle\\Commons\\Http\\Factory\\RequestFactory**: Creates client-side requests.
- **Waffle\\Commons\\Http\\Factory\\ServerRequestFactory**: Creates server-side requests.
- **Waffle\\Commons\\Http\\Factory\\ResponseFactory**: Creates responses.
- **Waffle\\Commons\\Http\\Factory\\StreamFactory**: Creates streams from strings, files, or resources.
- **Waffle\\Commons\\Http\\Factory\\UriFactory**: Creates URI objects.
- **Waffle\\Commons\\Http\\Factory\\UploadedFileFactory**: Creates uploaded file objects.

Example creating a stream:

```
use Waffle\Commons\Http\Factory\StreamFactory;

$factory = new StreamFactory();
$stream = $factory->createStream('Hello World');

echo $stream->getContents(); // "Hello World"
```

Features
--------

[](#features)

- **PSR-7:** Full implementation of `Request`, `Response`, `ServerRequest`, `Stream`, `Uri`, `UploadedFile`.
- **PSR-17:** Full implementation of Factories for all HTTP objects.
- **Response Emitter:** A simple emitter to output PSR-7 responses to the browser.
- **Lightweight:** Minimal dependencies, focused on performance.
- **Strict Typing:** Built with PHP 8.4+ strict types for reliability.
- **Zero Dependencies:** No external dependencies other than psr/http-message and psr/http-factory.
- **Secure by Design:** Robust handling of headers, file uploads, and streams.

Testing
-------

[](#testing)

This component is fully tested with PHPUnit.

```
composer tests
```

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

[](#contributing)

Contributions are welcome! Please refer to [CONTRIBUTING.md](./CONTRIBUTING.md) for details.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE.md](./LICENSE.md) file for details.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance79

Regular maintenance activity

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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

Total

3

Last Release

133d ago

PHP version history (2 changes)0.1.0-alpha1PHP ^8.4

0.1.0-alpha4PHP ^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/34a7557a3fb23aaf788ca3892b9b7efdf96e753264bafd0599153c9e8a921316?d=identicon)[LesliePetrimaux](/maintainers/LesliePetrimaux)

---

Top Contributors

[![supa-chayajin](https://avatars.githubusercontent.com/u/695448?v=4)](https://github.com/supa-chayajin "supa-chayajin (38 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/waffle-commons-http/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

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

RoadRunner: HTTP and PSR-7 worker

779.2M48](/packages/spiral-roadrunner-http)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[art4/requests-psr18-adapter

Use WordPress/Requests as a PSR-18 HTTP client

153.3k](/packages/art4-requests-psr18-adapter)

PHPackages © 2026

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