A fluent vocabulary.
Set headers, authentication, timeouts, and request defaults. Keep the details close to the call.
Configure requestsFetchPHP / HTTP for modern PHP
A familiar fetch API. The power of Guzzle. From your first request to concurrent workflows, write HTTP that feels at home in PHP.
composer require jerome/fetch-phpGETapi.example.test/v1/users/42
$response = fetch(
'https://api.example.test/v1/users/42',
);
if ($response->successful()) {
$user = $response->json();
}Autoloading and offline test fakes omitted for clarity. View runnable examples →
PHP 8.3+ Guzzle 7.9+ Matrix 4 PSR-7 / PSR-18
A small surface. A capable client.
One request shouldn’t need a ceremony. A growing application shouldn’t need a different HTTP client.
$client = fetch_client([
'base_uri' => 'https://api.example.test/v1/',
'headers' => ['Accept' => 'application/json'],
'timeout' => 5,
]);
$response = $client->get('users');Real API. Offline-tested examples. See the full source →
Set headers, authentication, timeouts, and request defaults. Keep the details close to the call.
Configure requestsRead JSON, inspect status codes, or work directly with the underlying PSR-7 message.
Handle responsesAdd retries, opt-in HTTP caching, middleware, and request validation as your application grows.
Explore the guides Familiar by design.
Flexible by default.
Concurrency, with intention
Enable async transport on a handler. Compose its promises with Matrix. Work with the results when they’re ready.
Meet the async APIasync() An explicit boundary. Synchronous helpers stay synchronous. use Fetch\Http\ClientHandler;
use Fetch\Testing\MockResponse;
use Fetch\Testing\MockServer;
$client = ClientHandler::create()->async();
$responses = await(all([
'users' => $client->get('https://api.example.test/users'),
'posts' => $client->get('https://api.example.test/posts'),
]));Illustrative · autoloading and offline test fakes omitted. Runnable source ↗
Your next request starts here
Start with one request. Find your rhythm. The documentation takes it from there.