PHPackages                             pact/pact - 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. pact/pact

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

pact/pact
=========

Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

0.2.1(10y ago)834.7k4[1 PRs](https://github.com/mopoke/pact-php/pulls)MITPHP

Since Sep 17Pushed 8y ago2 watchersCompare

[ Source](https://github.com/mopoke/pact-php)[ Packagist](https://packagist.org/packages/pact/pact)[ RSS](/packages/pact-pact/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

Pact-PHP
========

[](#pact-php)

Define a pact between service consumers and providers, enabling "consumer driven contract" testing.

[![Build Status](https://camo.githubusercontent.com/064e9bc903df48315eca0978de916525835293708f8de20421fad172ee4e0cf4/68747470733a2f2f7472617669732d63692e6f72672f6d6f706f6b652f706163742d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mopoke/pact-php)

How to use
----------

[](#how-to-use)

1. Install pact mock service:

    1. Install Ruby and Ruby Gems
    2. Write a Gemfile:

        ```
        source 'https://rubygems.org'
        gem 'pact-mock_service', '~> 0.7.0'
        ```
    3. Run bundler to get the gems: `gem install bundler && bundle install`
2. Install composer: `curl -sS https://getcomposer.org/installer | php`
3. Install dependencies: `php composer.phar install`
4. Write a phpunit test similar to the following:

    ```
    public function testMyProvider() {
      $client = new ZooClient('http://localhost:1234');

      $alligatorProvider = Pact::mockService([
        'consumer' => 'Alligator Consumer',
        'provider' => 'Alligator Provider',
        'port' => 1234
      ]);

      $alligatorProvider
        ->given("an alligator with the name Mary exists")
        ->uponReceiving("a request for an alligator")
        ->withRequest("get", "/alligators/Mary", [
          "Accept" => "application/json"
        ])->willRespondWith(200, [
          "Content-Type" => "application/json"
        ], [
          "name" => "Mary"
        ]);

      $alligatorProvider->run(function() use ($client) {
        $alligator = $client->getAlligatorByName('Mary');
        $this->assertInstanceOf("Alligator", $alligator);
        $this->assertEquals("Mary", $alligator->getName());
      });
    }
    ```
5. Start the mock server: `bundle exec pact-mock-service -p 1234 --pact-specification-version 2.0.0 -l log/pact.logs --pact-dir tmp/pacts`
6. Run phpunit: `./vendor/bin/phpunit`
7. Inspect the pact file in `tmp/pacts`

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

3

Last Release

3892d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e38dd12e65d4cde74e283409d745b2765e799bafd8ccd13c9cd05657b0474156?d=identicon)[mopoke](/maintainers/mopoke)

---

Top Contributors

[![andykelk](https://avatars.githubusercontent.com/u/3691521?v=4)](https://github.com/andykelk "andykelk (21 commits)")

---

Tags

pact

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78768.9M1.5k](/packages/phpstan-phpstan-symfony)

PHPackages © 2026

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