Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Http Laravel Package

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...

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Transport-layer abstraction for non-framework PHP services. If your product ships a lightweight HTTP surface (webhooks, reverse proxies, API gateways, middleware, custom routers) outside a full framework, 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.
  • Build vs. buy on HTTP primitives. Comparing "write our own request/response objects" vs. "adopt a package," this is a credible middle option — you get mockable, DI-friendly interfaces and a SAPI bridge without pulling in a framework. It also frames the more important buy-vs-buy decision: sabre/http vs. Symfony HttpFoundation, which the README explicitly recommends considering.
  • Feature bets enabled cheaply by the bundled cURL client. The built-in 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.
  • Extensibility strategy through decorators. The 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.
  • Testability and dependency-injection posture. Because everything typehints on 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.
  • Reverse-proxy and edge-routing use cases. The documented proxy recipe (clone request, strip 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.
  • Legacy-surface and versioning decisions. Clear PHP minimums per release line (5.4 → 7.1 → 7.4) inform a support-matrix decision: which of your products can adopt it now and what PHP floor you're committing to.

When to Consider This Package

Consider it when:

  • You need a small HTTP request/response toolkit — not a full framework — and want typed, injectable, mockable objects instead of raw superglobals.
  • Your codebase is already in the sabre ecosystem (e.g., sabre/dav) or you are building on sabre interfaces; adopting this avoids a second, redundant HTTP abstraction.
  • You want a decorator-based extension model so multiple subsystems can add behavior (auth, tenancy, telemetry) without subclassing core types or controlling instantiation.
  • You need a occasional outbound HTTP client with event hooks and async support, and Guzzle is overkill for the handful of calls you make.
  • You are prototyping a reverse proxy, webhook relay, or middleware shim and want the shortest path from $_SERVER to a forwardable Request object.
  • PHP 7.4+ is acceptable and BSD-3-Clause is compatible with your licensing posture.

Look elsewhere when:

  • You are on a full-stack framework. Symfony, Laravel, and Slim already ship HttpFoundation or PSR-7 equivalents; adding sabre/http creates two parallel transport abstractions.
  • You need PSR-7/PSR-15/PSR-18 compliance for interoperability with the wider PHP ecosystem. This library is interface-compatible in spirit but not PSR-standard, so bridging costs offset its simplicity.
  • You need a production-grade outbound HTTP client: connection pooling, middleware stacks, PSR-18 compliance, mature retry/backoff, or rich async — Guzzle is the safer bet, and the README says as much.
  • Signals to weigh: 190 stars, 0 listed dependents, and no active ecosystem pull. That is a low-velocity, low-visibility dependency. If your product needs long-term community support, security triage, or a hiring pool familiar with the API, HttpFoundation dominates on every one of those axes.
  • You need strict HTTP/2, streaming-upload, or sophisticated content-negotiation features; the surface here is deliberately basic.

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.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console