All projects

Open-source project

Fetch PHP

Modern PHP HTTP client inspired by JavaScript's fetch API. Async/await, streaming, SSE, middleware, RFC 7234 caching, and full PSR-7/18 compliance.

451 stars27 forksPHP

About the project

Fetch PHP is a Guzzle-based HTTP client for PHP with a small global fetch() helper, an object-oriented client, PSR-7 and PSR-18 support, streaming, middleware, retries, and optional caching.

The API takes inspiration from JavaScript Fetch. It uses PHP values and Guzzle request options, and it does not implement the browser Fetch API or its security model.

Runtime packages: Guzzle 7.9+, PSR-7 1.x/2.x, PSR-3 1.x/2.x/3.x, ReactPHP event-loop and promise packages, and jerome/matrix ^4.0

Problem

PHP developers often reach for powerful HTTP clients that can feel heavier than necessary for straightforward product work. Fetch PHP focuses on a familiar, low-friction request model.

Architecture

A small PHP package that wraps request construction, execution, and response handling behind predictable developer-facing primitives.

Design decisions

  • Keep the public API close to the mental model developers already know from fetch-style clients.
  • Make common JSON and response flows easy while preserving access to lower-level HTTP behavior.
  • Treat documentation examples as part of the API surface.

Constraints and lessons

Constraints

  • Compatibility matters because package users build workflows around existing behavior.
  • The library has to stay small enough to remain easy to understand and maintain.

Lessons

  • Familiar APIs create useful adoption, but they also create expectations that must be respected.
  • Defaults, naming, and documentation are product decisions, not afterthoughts.

Actively maintained as a public developer tool.