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.

450 stars28 forksPHP

About the project

Fetch PHP is a modern HTTP client library for PHP that brings JavaScript's fetch API experience to PHP. Built on top of Guzzle, Fetch PHP allows you to write HTTP code with a clean, intuitive JavaScript-like syntax while still maintaining PHP's familiar patterns.

With support for both synchronous and asynchronous requests, a fluent chainable API, and powerful retry mechanics, Fetch PHP streamlines HTTP operations in your PHP applications.

Key Features JavaScript-like Syntax : Write HTTP requests just like you would in JavaScript with the fetch() function and async / await patterns Promise-based API : Use familiar .then() , .catch() , and .finally() methods for async operations Fluent Interface : Build requests with a clean, chainable API Built on Guzzle : Benefit from Guzzle's robust functionality with a more elegant API Streaming & Server-Sent Eve…

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.