Temant HTTP Core is a lightweight implementation of the PSR-7 HTTP message interfaces and the PSR-17 HTTP message factory interfaces. It provides a clean and modern foundation for working with HTTP requests, responses, streams, URIs, and uploaded files in PHP.
The goal of this library is to offer a simple and standards-compliant package written for modern PHP without unnecessary overhead.
- Fully compliant with PSR-7 and PSR-17
- Focused and minimal API surface
- Immutable message objects
- Supports all HTTP message components, including headers, bodies, uploaded files and URIs
- Tested and analyzed with PHPUnit and PHPStan
- PHP 8.4or higher
- psr/http-message^2.0
- psr/http-factory^1.1
Install via Composer:
composer require temant/http-core<?php
declare(strict_types=1);
require_once __DIR__ . "/vendor/autoload.php";
use Temant\HttpCore\Factory\RequestFactory;
use Temant\HttpCore\Factory\ResponseFactory;
use Temant\HttpCore\Factory\StreamFactory;
// Create a request instance
$request = new RequestFactory()
    ->createRequest('GET', 'https://example.com');
// Create a response with text content
$stream = new StreamFactory()
    ->createStream('Hello Temant');
$response = new ResponseFactory()
    ->createResponse()
    ->withBody($stream);
echo $response->getStatusCode(); // 200
echo $response->getBody();       // Hello TemantAdditional examples for headers, query parameters, uploaded files, and streams will be added soon.
Run the test suite:
composer testRun static analysis:
composer analyseThis library is compatible with the official http-interop/http-factory-tests.
Src/
Tests/
composer.json
Autoloading follows PSR-4 for both source and test directories.
Contributions are welcome. Please ensure that new code includes relevant tests. Bug reports and improvement suggestions are appreciated.
Temant HTTP Core is open-sourced software licensed under the MIT license.