guzzlehttp/test-server

Node.js server and PHP controller

Maintainers

Package info

github.com/guzzle/test-server

pkg:composer/guzzlehttp/test-server

Transparency log

Statistics

Installs: 326 376

Dependents: 8

Suggesters: 0

Stars: 14

Open Issues: 0

1.0.0 2026-07-20 13:59 UTC

This package is auto-updated.

Last update: 2026-07-20 13:59:35 UTC


README

guzzlehttp/test-server is a testing helper for PHP HTTP clients. It starts a local Node.js HTTP server, lets your tests queue responses, and records the requests your client sends.

Most Guzzle client tests should use Guzzle's MockHandler and History Middleware instead of a real server. Use this package for handler tests and integration tests that need a predictable HTTP endpoint. It is not intended to be a general-purpose web server or a production dependency.

Installation

composer require --dev guzzlehttp/test-server

The server requires Node.js ^20.19 || ^22.13 || >=24 available as node.

Version Guidance

Version Status PHP Version
1.0 Latest >=7.4,<8.6
0.7 Maintenance >=7.2.5,<8.6

Quick Start

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Server\Server;

$client = new Client();

Server::start();
register_shutdown_function(static function (): void {
    Server::stop();
});

Server::enqueue([
    new Response(201),
]);

$response = $client->request('GET', Server::$url);
echo $response->getStatusCode();
// 201

$requests = Server::received();
echo $requests[0]->getMethod();
// GET

Documentation

License

Guzzle Test Server is made available under the MIT License (MIT). Please see License File for more information.