sabre/http
sabre/http wraps PHP's messy superglobals and header()/echo output into clean, mockable Request and Response objects. Instantiate once via Sapi::getRequest(), then pass it around with dependency injection, typehinting on RequestInterface. A lightweight alternative to Symfony HttpFoundation, born fro...
sabre/http lets you decide to standardize on a small, dependency-free Request/Response contract rather than hand-rolling $_SERVER/header() handling in each service.sabre/http vs. Symfony HttpFoundation, which the README explicitly recommends considering.Client (sync, async via cURL multi, event hooks for beforeRequest/afterRequest/error:*) makes small outbound-integration features — third-party API calls, retry-on-401 auth refresh, parallel webhook fan-out, reverse-proxy endpoints — cheap enough to prototype before committing roadmap budget to a heavier HTTP client like Guzzle.RequestDecorator pattern is a decision enabler: you can layer domain concepts (auth state, tenant context, feature flags) onto requests per subsystem without forking or locking the core types. That supports a "compose behaviors, don't subclass the transport" architectural policy.RequestInterface/ResponseInterface and the objects are "extendable and easily mockable," you can make the call that HTTP concerns are injectable seams — a prerequisite for unit-testing request-handling logic without spinning up a server.Host, rewrite URL, forward, send response) is a concrete signal for scoping edge features — BFF/proxy tiers, preview environments, request mirroring — as small increments rather than platform projects.Consider it when:
sabre/dav) or you are building on sabre interfaces; adopting this avoids a second, redundant HTTP abstraction.$_SERVER to a forwardable Request object.BSD-3-Clause is compatible with your licensing posture.Look elsewhere when:
HttpFoundation or PSR-7 equivalents; adding sabre/http creates two parallel transport abstractions.HttpFoundation dominates on every one of those axes.Net PM read: adopt only for narrow, well-bounded internal use (proxy shims, small webhook/edge services) or when you are already inside the sabre stack. Do not make it the transport foundation of a greenfield product that expects ecosystem integration.
To executives: This is a small, permissively licensed (BSD-3) PHP library that wraps PHP's awkward HTTP globals into clean Request and Response objects. It is cheap to adopt and lets us ship HTTP-adjacent features — webhook relays, lightweight proxies, outbound API calls — without buying or building a framework. The honest caveat: it is a low-traffic project (~190 stars, no listed dependents) that directly overlaps with Symfony's far more popular HttpFoundation, and the maintainers themselves point users there. So the recommendation is targeted adoption, not platform standardization: use it where it saves weeks on a bounded feature, and default to HttpFoundation anywhere we need ecosystem depth, hiring familiarity, or long-term support guarantees. Cost of being wrong is low — the abstraction is thin and swapping it out is a contained engineering task.
To engineering: The value proposition is threefold. (1) A DI-friendly RequestInterface/ResponseInterface contract — typehint on the interface, instantiate once via Sapi::getRequest(), send once via Sapi::sendResponse() — which makes HTTP handling testable with mocks and keeps transport out of business logic. (2) A first-class decorator pattern (RequestDecorator/ResponseDecorator) so we can attach auth, tenant, or telemetry context per subsystem without subclassing or overriding factories — this is the architecturally correct extension seam and the docs are explicit about why inheritance is the wrong path. (3) A bundled cURL client with beforeRequest/afterRequest/error:* hooks and async support, adequate for occasional outbound calls but explicitly not a Guzzle replacement. Requirements: PHP 7.4+, Composer, and awareness that body streams may be non-rewindable and getBodyAsString() is effectively single-read — plan accordingly for anything that inspects bodies twice. If we need PSR-7/15/18 interoperability or a feature-rich client, we should not force-fit this library.
How can I help you explore Laravel packages today?