PHPackages                             philharmony/http-factory - 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. philharmony/http-factory

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

philharmony/http-factory
========================

PSR-17 HTTP factory implementation for Philharmony

v1.1.0(2mo ago)024MITPHPPHP ^8.1CI passing

Since Mar 26Pushed 2mo agoCompare

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

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

http-factory
============

[](#http-factory)

[![Validate](https://github.com/philharmonytech/http-factory/actions/workflows/ci.yaml/badge.svg?job=validate)](https://github.com/philharmonytech/http-factory/actions/workflows/ci.yaml)[![Analysis](https://github.com/philharmonytech/http-factory/actions/workflows/ci.yaml/badge.svg?job=static-analysis)](https://github.com/philharmonytech/http-factory/actions/workflows/ci.yaml)[![Test](https://github.com/philharmonytech/http-factory/actions/workflows/ci.yaml/badge.svg?job=tests)](https://github.com/philharmonytech/http-factory/actions/workflows/ci.yaml)[![codecov](https://camo.githubusercontent.com/7d512eacab2b1be17143091841dd1076e867704a40750472fd186588d7d05879/68747470733a2f2f636f6465636f762e696f2f6769746875622f7068696c6861726d6f6e79746563682f687474702d666163746f72792f67726170682f62616467652e7376673f746f6b656e3d4a56474d31525241434b)](https://codecov.io/github/philharmonytech/http-factory)[![PHP Version](https://camo.githubusercontent.com/48b43ec8db6cfdd0d482cba4d9f310ad8aacc1dadd96ddda95bf9c2daad8bd52/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e31253230746f253230382e342d3838393242462e737667)](https://www.php.net/supported-versions.php)[![Latest Stable Version](https://camo.githubusercontent.com/83f5dee38090ac4472087c6a37df71d874ce271490a2d56b35735297eab87f32/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f7068696c6861726d6f6e79746563682f687474702d666163746f72793f6c6162656c3d737461626c65)](https://github.com/philharmonytech/http-factory/releases)[![Total Downloads](https://camo.githubusercontent.com/09b0e81f02aa6310b7712c1203fd6e0862780520650acefad272742b637c2b5d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068696c6861726d6f6e792f687474702d666163746f7279)](https://packagist.org/packages/philharmony/http-factory)[![License](https://camo.githubusercontent.com/c7336b9a7243831f7b7db359c2c681c29c684eb5031c096283295545efd5e9ee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068696c6861726d6f6e792f687474702d666163746f7279)](https://github.com/philharmonytech/http-factory/blob/main/LICENSE)

PSR-17 HTTP factory implementation for the Philharmony framework.

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

[](#installation)

```
composer require philharmony/http-factory
```

🚀 Usage
-------

[](#-usage)

### Create a Server Request

[](#create-a-server-request)

```
use Philharmony\Http\Factory\ServerRequestFactory;

$factory = new ServerRequestFactory();

$request = $factory->createServerRequest(
    'GET',
    'https://example.com'
);
```

### Create a Request with Body

[](#create-a-request-with-body)

```
use Philharmony\Http\Factory\RequestFactory;
use Philharmony\Http\Factory\StreamFactory;

$requestFactory = new RequestFactory();
$streamFactory = new StreamFactory();

$stream = $streamFactory->createStream('Hello, Philharmony');

$request = $requestFactory->createRequest('POST', 'https://example.com')
    ->withBody($stream);
```

### Create a Response

[](#create-a-response)

```
use Philharmony\Http\Factory\ResponseFactory;

$response = (new ResponseFactory())->createResponse(200);
```

### Create a Stream

[](#create-a-stream)

```
use Philharmony\Http\Factory\StreamFactory;

$streamFactory = new StreamFactory();

// From string
$stream = $streamFactory->createStream('Hello');

// From file
$stream = $streamFactory->createStreamFromFile('/path/to/file.txt');

// From resource
$stream = $streamFactory->createStreamFromResource(fopen('php://temp', 'r+'))
```

### Create an Uploaded File

[](#create-an-uploaded-file)

```
use Philharmony\Http\Factory\UploadedFileFactory;
use Philharmony\Http\Factory\StreamFactory;

$stream = (new StreamFactory())->createStream('file content');

// From stream
$uploadedFile = (new UploadedFileFactory())->createUploadedFile(
    $stream,
    $stream->getSize(),
    UPLOAD_ERR_OK,
    'file.txt',
    'text/plain'
);

// From file
$uploadedFileFromFile = (new UploadedFileFactory())->createUploadedFileFromFile(
    fileOrStream: '/path/to/file.txt',
    size: null, // used filesize
    errorStatus: UPLOAD_ERR_OK,
    clientFilename: 'file.txt',
    clientMediaType: 'text/plain',
    fullPath: '/path/to/file.txt' // PHP 8.1+ support
);
```

### Create a URI

[](#create-a-uri)

```
use Philharmony\Http\Factory\UriFactory;

$uri = (new UriFactory())->createUri('https://example.com/path');
```

🧪 Testing
---------

[](#-testing)

The package is strictly tested with PHPUnit 10 to ensure full compliance with HTTP standards and RFCs.

### Run Tests

[](#run-tests)

```
composer test
```

### Code Coverage

[](#code-coverage)

```
composer test:coverage
```

🏗️ Static Analysis &amp; Code Style
-----------------------------------

[](#️-static-analysis--code-style)

Verified with PHPStan Level 9 to ensure total type safety and prevent runtime errors.

```
composer phpstan
```

Check and fix code style (PSR-12):

```
composer cs-check
composer cs-fix
```

📄 License
---------

[](#-license)

This package is open-source and licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

🤝 Contributing
--------------

[](#-contributing)

Contributions, issues, and feature requests are welcome.

If you find a bug or have an idea for improvement, please open an issue or submit a pull request.

⭐ Support
---------

[](#-support)

If you find this package useful, please consider giving it a star on GitHub. It helps the project grow and reach more developers.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance83

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Total

2

Last Release

88d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4cd2e09bafc7c15e943d0844b81b7cbfe022c3b13a5cfe59b158e01e11a0658?d=identicon)[it-philharmony](/maintainers/it-philharmony)

---

Top Contributors

[![Vyacheslav86RUS](https://avatars.githubusercontent.com/u/51032800?v=4)](https://github.com/Vyacheslav86RUS "Vyacheslav86RUS (12 commits)")

---

Tags

httpfactorypsr-17philharmony

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/philharmony-http-factory/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B3.8k](/packages/guzzlehttp-psr7)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28146.3k](/packages/phpro-http-tools)[laminas/laminas-stratigility

PSR-7 middleware foundation for building and dispatching middleware pipelines

577.0M95](/packages/laminas-laminas-stratigility)[laudis/neo4j-php-client

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

185671.3k41](/packages/laudis-neo4j-php-client)[mezzio/mezzio-authentication-oauth2

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

28545.4k3](/packages/mezzio-mezzio-authentication-oauth2)

PHPackages © 2026

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