Skip to content

Add configurable HTTP server factory to browser configuration - #263

Open
matt-h wants to merge 1 commit into
pestphp:5.xfrom
matt-h:configurable-http-server
Open

matt-h wants to merge 1 commit into
pestphp:5.xfrom
matt-h:configurable-http-server

Conversation

@matt-h

@matt-h matt-h commented Sep 15, 2026

Copy link
Copy Markdown

Description

Adds support for configuring a custom HTTP server factory through the browser configuration API. This lets integrations provide their own HttpServer implementation while preserving the default server behavior.

Adds tests covering factory usage, URL rewriting, and the guard against changing the factory after the server has been created.

The Pest Browser Plugin includes a LaravelHttpServer and NullableHttpServer but no way to extend this with your own class.

This change allows anyone to set their own HttpServer class in their project to configure it how they want.

For example:

pest()->browser()->httpServer(static fn (): ExampleHttpServer => new ExampleHttpServer);

Reasoning

I am working on building https://packagist.org/packages/crosspeak/wp-pest which is WordPress support for Pest.

This change allows allows me configure Pest Browser to dynamically read the WordPress setup so requests like visit('/') will resolve to the correct urls.

Adds support for configuring a custom HTTP server factory through the browser configuration API. This lets integrations provide their own HttpServer implementation while preserving the default server behavior.

Adds tests covering factory usage, URL rewriting, and the guard against changing the factory after the server has been created.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant