amphp/http
Event-driven HTTP primitives for PHP 8.1+ in the AMPHP ecosystem. Provides shared building blocks for HTTP clients and servers, including IANA status codes with default reasons, RFC 6265 cookie parsing/creation (Set-Cookie/Cookie), and header utilities.
This package provides low-level HTTP abstractions (like Request, Response, Headers, Message, Status) — not a full framework or standalone HTTP server/client. Start by examining src/Request.php, src/Response.php, and src/Status.php to understand the core types. Use it when building your own HTTP client/server libraries (e.g., over Amp’s event loop), where interoperability with PSR-7/15/17 is desired. First use case: normalize incoming requests in a custom HTTP server implementation by wrapping raw server data in Amp\Http\Message types.
ServerRequest → Amp\Http\Message\Request).Amp\Http\Psr adapter (if present) to translate between PSR-7/17 and Amp’s native types — ideal for hybrid libraries.Amp\Http\Message\Stream for efficient memory-constrained transfers (e.g., proxying large files or SSE streams).Request/Response directly in unit tests without touching nette/tester or Guzzle — e.g., $request = new Request('GET', '/health');.amphp/artax (client) or amphp/http-server for full stacks.$headers->get('Content-Type') instead of $headers['content-type'].Stream instances are often non-seekable or non-readable after read — never assume rewinding is safe unless documented (e.g., BufferedStream).Message to add project-specific metadata (e.g., TrackedRequest extends Request) for logging/tracing — avoid mutating core classes directly.amphp/http and a PSR implementation (e.g., nyholm/psr7) in require/require-dev.How can I help you explore Laravel packages today?