PHPackages                             cobiro/wiremock - 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. cobiro/wiremock

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

cobiro/wiremock
===============

Wiremock library for easier integration with PHPUnit.

3.0.0(1y ago)721.0k↓91.7%3[1 issues](https://github.com/Cobiro/wiremock-phpunit/issues)[1 PRs](https://github.com/Cobiro/wiremock-phpunit/pulls)MITPHPPHP ^8.1CI failing

Since Apr 20Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Cobiro/wiremock-phpunit)[ Packagist](https://packagist.org/packages/cobiro/wiremock)[ RSS](/packages/cobiro-wiremock/feed)WikiDiscussions 1.x Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (21)Used By (0)

PHPUnit extension for WireMock
------------------------------

[](#phpunit-extension-for-wiremock)

This library provides easy way to integrate [WireMock](https://wiremock.org) with PHPUnit. It will verify mocked interactions after each test and fail them if they are not met.

### Requirements

[](#requirements)

- Running wiremock service(in tests we use `wiremock/wiremock:latest`)
- Set up `WIREMOCK_HOST` and `WIREMOCK_PORT` in env variables of `phpunit.xml`
- PHP 8
- PHPUnit 9.3 or higher
- wiremock-php 2.0 or higher

### Usage

[](#usage)

There are few ways to use this extension, each varies on level on how deeply you are open to modify your tests. First you need to add extension to your `phpunit.xml` configuration:

```

```

We suggest using this extension for most convenient usage:

#### WireMock\\Phpunit\\Extension\\WireMockExtension

[](#wiremockphpunitextensionwiremockextension)

This extension doesn't provide verification after each test. To verify interactions your test case need to extend `WireMock\Phpunit\WireMockTestCase` or you need to use `WireMock\Phpunit\WireMockVerificationTrait`. Both solutions are triggering verification on teardown. Using this extension gives you nice response of failed tests. Also it doesn't stop on first failed verification.

#### WireMock\\Phpunit\\Extension\\WireMockVerificationExtension

[](#wiremockphpunitextensionwiremockverificationextension)

This extension triggers verification automatically after each test, but it comes with caveat that it fails after first failed interaction, so we are not recommending this way. But with this you don't need to extend our test case or add a new trait to existing test cases.

#### Mocking requests

[](#mocking-requests)

To mock requests you need to use `WireMock\Phpunit\WireMockTrait::wireMock()`. We recommend creating your own traits with your own methods. This is one of examples:

```
trait RequestTrait
{
    use WireMockTrait;

    public function mockTestRequest(string $expectedBody): void
    {
        $this->wireMock(
            'GET',
            '/test',
            [],
            null,
            [],
            $expectedBody
        );
    }

    public function mockTestPostRequest(string $expectedBody, string $requestBody): void
    {
        $this->wireMock(
            'POST',
            '/test',
            [],
            $requestBody,
            [],
            $expectedBody
        );
    }
}
```

### Configuration

[](#configuration)

By default, extension waits for 3 seconds for wiremock server. If you need more time you can change it by setting environment variable `WIREMOCK_TIMEOUT`

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance44

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 76.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~25 days

Total

19

Last Release

400d ago

Major Versions

1.1.0 → 2.1.02023-05-17

1.1.1 → 2.1.22023-06-06

1.1.2 → 2.1.32024-01-10

1.1.3 → 2.1.52025-02-18

2.x-dev → 3.0.02025-05-29

PHP version history (2 changes)1.0.0PHP ^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b299e0c2e35e17d16e26267437933443688e14086e71759d3cb3f0f40747db16?d=identicon)[wsj-cobiro](/maintainers/wsj-cobiro)

---

Top Contributors

[![Jurigag](https://avatars.githubusercontent.com/u/10086991?v=4)](https://github.com/Jurigag "Jurigag (20 commits)")[![wsj-cobiro](https://avatars.githubusercontent.com/u/112582223?v=4)](https://github.com/wsj-cobiro "wsj-cobiro (5 commits)")[![mxr576](https://avatars.githubusercontent.com/u/1755573?v=4)](https://github.com/mxr576 "mxr576 (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cobiro-wiremock/health.svg)

```
[![Health](https://phpackages.com/badges/cobiro-wiremock/health.svg)](https://phpackages.com/packages/cobiro-wiremock)
```

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k136.1M986](/packages/brianium-paratest)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

30314.4k7](/packages/webmozarts-strict-phpunit)[markocupic/calendar-event-booking-bundle

Contao Calendar Event Booking Bundle

135.2k1](/packages/markocupic-calendar-event-booking-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
