PHPackages                             donatj/mock-webserver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. donatj/mock-webserver

ActiveLibrary[Testing &amp; Quality](/categories/testing)

donatj/mock-webserver
=====================

Simple mock web server for unit testing

v2.10.0(2mo ago)1382.5M—1.9%22[5 issues](https://github.com/donatj/mock-webserver/issues)[2 PRs](https://github.com/donatj/mock-webserver/pulls)20MITPHPPHP &gt;=7.2CI passing

Since Apr 25Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/donatj/mock-webserver)[ Packagist](https://packagist.org/packages/donatj/mock-webserver)[ Fund](https://www.paypal.me/donatj/15)[ GitHub Sponsors](https://github.com/donatj)[ RSS](/packages/donatj-mock-webserver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (38)Used By (20)

Mock Web Server
===============

[](#mock-web-server)

[![Latest Stable Version](https://camo.githubusercontent.com/dc7d7929ee106f318b2b4aa8a23f1bd4868fddb09848ef97279e956585788b9d/68747470733a2f2f706f7365722e707567782e6f72672f646f6e61746a2f6d6f636b2d7765627365727665722f76657273696f6e)](https://packagist.org/packages/donatj/mock-webserver)[![License](https://camo.githubusercontent.com/7a0dcaecb9ec83d80e244343a40ae59282e60ca3cf8cd6ba31901498b575d091/68747470733a2f2f706f7365722e707567782e6f72672f646f6e61746a2f6d6f636b2d7765627365727665722f6c6963656e7365)](https://packagist.org/packages/donatj/mock-webserver)[![ci.yml](https://github.com/donatj/mock-webserver/actions/workflows/ci.yml/badge.svg)](https://github.com/donatj/mock-webserver/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/094def7c6306df8a5441e5f4a210b85ecd11fe235755454ae193a7945e65ffac/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f646f6e61746a2f6d6f636b2d7765627365727665722f62616467652e737667)](https://coveralls.io/github/donatj/mock-webserver)

Simple, easy to use Mock Web Server for PHP unit testing. Gets along simply with PHPUnit and other unit testing frameworks.

Unit testing HTTP requests can be difficult, especially in cases where injecting a request library is difficult or not ideal. This helps greatly simplify the process.

Mock Web Server creates a local Web Server you can make predefined requests against.

Documentation
-------------

[](#documentation)

[See: docs/docs.md](docs/docs.md)

Requirements
------------

[](#requirements)

- **php**: &gt;=7.2
- **ext-sockets**: \*
- **ext-json**: \*
- **ralouphie/getallheaders**: ~2.0 || ~3.0

Installing
----------

[](#installing)

Install the latest version with:

```
composer require --dev 'donatj/mock-webserver'
```

Examples
--------

[](#examples)

### Basic Usage

[](#basic-usage)

The following example shows the most basic usage. If you do not define a path, the server will simply bounce a JSON body describing the request back to you.

```
