donatj/mock-webserver
Lightweight PHP mock web server for tests and local development. Spin up an HTTP server on a random port, enqueue canned responses, inspect received requests, and simulate endpoints reliably. Handy for integration tests without external services.
Notice: PHP 7.2 is now the minimum supported version because of a vulnerability with older versions of PHPUnit.
See: CVE-2026-24765 / GHSA-vvj3-c3rp-c85p for more information.
Fixes
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.9.0...v2.10.0
#81 - Nested ResponseByMethod does not work with ResponseStack in sequential requests by @juslintek
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.8.0...v2.9.0
The hashes generated by donatj\MockWebServer\Response::getRef have changed.
While this value was generally for internal use, it was not marked as such so this is a breaking change.
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.7.3...v2.8.0
Adds phpstan, makes appropriate fixes
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.7.2...v2.7.3
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.7.1...v2.7.2
Backports descriptor fix from v2.7.1 onto the v2.6.x release
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.6.2...v2.6.3
Fixed an issue with 'files' stream wrappers not being able to handle [file, path, mode] syntax - thanks to @sigma-z
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.7.0...v2.7.1
DelayedResponse now implements InitializingResponseInterface to enable support for sub-responses that implement InitializingResponseInterface - Thanks @Jarlakxen
Massively improved test coverage.
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.6.2...v2.7.0
Fixes a regression where the path to the server script was not being escaped, causing problems if there was a space anywhere in the path.
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.6.1...v2.6.2
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.6.0...v2.6.1
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.5.0...v2.6.0
Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.4.1...v2.5.0
#[ReturnTypeWillChange] for PHP 8.1 support by @brotkrueml in https://github.com/donatj/mock-webserver/pull/35Full Changelog: https://github.com/donatj/mock-webserver/compare/v2.4.0...v2.4.1
PHP 8 support added. No major changes.
Special thanks to @SilvioPahrig for correcting a small bug in the temporary directory pathing with #24
Also contains some minor housekeeping as seen here https://github.com/donatj/mock-webserver/compare/2985505...5f0f43d
The largest change here is dropping official support for HHVM. While it likely will work in HHVM, getting it to continually work in Travis was simply not worth the effort.
Widens the required version of ralouphie/getallheaders to include 3.x to help people with dependency issues.
Notes the already required ext-json dependency for composer.
Small testing and documentation updates.
Lots of minor code cleanup and CI finagling.
ResponseByMethod object to allow varying responses per HTTP Method.getLastRequest and getRequestByOffset now return RequestInfo objects rather than data arraysSmall interface change, major rewrite!
This corrects a bug where you'd get a JSON body if you'd requested an empty string body.
A number of fixes from the first beta for PHP5 specifically.
Beta This is a major breaking release.
Switches to a more object oriented system. The biggest change for the interface is you need to pass the methods setResponseOfPath and getUrlOfResponse Response donatj\MockWebServer\Responseobjects rather than body/headers/status.
This also adds the useful ResponseStack which allows you to line up multiple ordered responses on a single endpoint.
Adds a getRequestByOffset method that allows you to inspect requests other than just the most recent.
That's it, just a very minor note that it requires ext-sockets as it was an issue for me.
If you don't specify a port, we will now automatically ask the OS for an open port to use.
How can I help you explore Laravel packages today?