Search by

raxos / http

basmilius

Http client and foundation.

3.2.0 2026-10-03 10:45 UTC

README

Bas Milius

Raxos HTTP

Incoming requests, outgoing responses, HTTP clients, validation and file streaming.

Documentation | Packagist | Raxos

  • Typed request maps, headers, methods, status codes and uploaded files.
  • JSON, HTML, redirects, files and empty response types.
  • A client using Guzzle and PSR-7, PSR-17 and PSR-18 adapters.
  • Validation through PHP attributes and streamed byte-range responses.

Installation

Requires PHP 8.5 or later. Enable the ctype, fileinfo, mbstring PHP extensions. Composer checks the remaining package and extension dependencies declared in composer.json.

composer require "raxos/http:^3.2"

Usage

<?php
declare(strict_types=1);

use Raxos\Http\HttpMethod;
use Raxos\Http\HttpRequest;
use Raxos\Http\Response\JsonHttpResponse;

require __DIR__ . '/vendor/autoload.php';

$request = HttpRequest::create(method: HttpMethod::GET, uri: '/products?limit=25');
$limit = (int)$request->query->get('limit');

$response = new JsonHttpResponse(['items' => [], 'limit' => $limit]);
$response->send();

Use HttpRequest::createFromGlobals() at an HTTP entry point. Invalid or scalar JSON bodies are rejected when parsed as structured JSON. File streaming defaults to no throttle; invalid or multiple byte ranges return HTTP 416. Set a positive throttle explicitly when needed.

Documentation

Testing

Run this library's Pest suite from the Raxos workspace:

git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=http

See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.

License

MIT. Copyright (c) 2017 - present Bas Milius.