🦖
[■] codesaur/http-message 1=[↕]
codesaur/http-message · v3.0.4

HTTP Message

Clean, minimal, object-oriented HTTP Message component (PSR-7)

Packagist version Downloads PHP version License Aikido Intel 98/100 PSR-7
1:1 ══ composer require codesaur/http-message
[■] HTTP Message

A lightweight component implementing the HTTP message building blocks of PSR-7 - Request, Response, ServerRequest, URI, Stream, UploadedFile and OutputBuffer. It can be used standalone, independent of any framework.

Features
  • Full PSR-7 MessageInterface, RequestInterface, ResponseInterface implementation
  • ServerRequest - reconstructs the request from globals ($_SERVER, $_GET, $_POST, $_FILES)
  • Uri - PSR-7 UriInterface with immutable with* methods
  • Stream, Output - StreamInterface implementations with output buffering
  • UploadedFile - uploaded file metadata + moveTo()
  • NonBodyResponse - lightweight body-less response (fallback prototype)
  • No external dependencies

Core classes

ClassPurpose
MessagePSR-7 MessageInterface implementation (headers, protocol, body)
RequestPSR-7 RequestInterface
ResponsePSR-7 ResponseInterface
ServerRequestReconstructs the request from the global environment
UriPSR-7 UriInterface
StreamPSR-7 StreamInterface implementation
UploadedFileUploaded file metadata + moveTo()
OutputStreamInterface implementation (output buffering)

Quick example

use codesaur\Http\Message\ServerRequest;
use codesaur\Http\Message\Response;

// ServerRequest үүсгэх / Create ServerRequest
$request = (new ServerRequest())->initFromGlobal();

// Query params
$query = $request->getQueryParams();

// PSR-7 headers унших / Read PSR-7 headers
$contentType = $request->getHeaderLine('Content-Type');
$csrfToken = $request->getHeaderLine('X-CSRF-TOKEN');

// Response үүсгэх / Create Response
$response = (new Response())
    ->withStatus(200)
    ->withHeader('Content-Type', 'application/json');

// Body-д бичих / Write to body
$response->getBody()->write(json_encode(['message' => 'Hello, World!']));

Running tests

composer test
[■] Info
Install
composer require codesaur/http-message
Requirements
  • PHP 8.2.1+
  • ext-json
  • Composer
Aikido score 98/100
Checked: 2026-09-10
Links