Skip to content
Greg Bowler edited this page May 3, 2025 · 8 revisions

The Fetch API provides an interface for fetching resources, typically across the network. It's a web standard, defined at https://fetch.spec.whatwg.org/#fetch-method.

The Fetch API is a standard feature of modern browsers and is familiar to most web developers.

This project brings the fetch API to the server in PHP, so you can use the same syntax and promise-based workflow as in JavaScript, enabling both blocking and non-blocking HTTP requests within your PHP applications. Since version 1.2.1, await functions are available to simplify working with Promises by directly returning their resolved value.

Why do we need yet another HTTP library?

There are already so many HTTP libraries in the PHP ecosystem. If you want to use the most popular, use Guzzle. If you want the simplest (and built-in to PHP), use cURL. Nearly every PHP developer will be familiar with these two APIs. So why do we need another?

PHP.Gt's mission is to bring well-known web standards to server-side PHP development. By adopting the Fetch API on the server, developers can write code that feels consistent across client and server environments. This reduces cognitive overhead, especially in full-stack or isomorphic applications, and encourages cleaner, more declarative code. Rather than inventing new paradigms for the server, this library embraces the same standards that developers already know and trust from the web platform.


Take a look at some usage examples.

Clone this wiki locally