PHPackages                             phiremock/phiremock-codeception-extension - 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. phiremock/phiremock-codeception-extension

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

phiremock/phiremock-codeception-extension
=========================================

Codeception extension for PhireMock. Allows to stub remote services for HTTP requests.

v1.5.5(8y ago)0287GPL-3.0-or-laterPHPPHP &gt;=5.6

Since Mar 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/andriuspetrauskis/phiremock-codeception-extension)[ Packagist](https://packagist.org/packages/phiremock/phiremock-codeception-extension)[ RSS](/packages/phiremock-phiremock-codeception-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (22)Used By (0)

phiremock-codeception-extension
===============================

[](#phiremock-codeception-extension)

Codeception extension and module to make working with [Phiremock](https://github.com/mcustiel/phiremock) even easier. It allows to start a Phiremock server specifically for the acceptance tests to run or to connect to an already running Phiremock server.

[![Latest Stable Version](https://camo.githubusercontent.com/f83e6ba75cb76123715019009d5e65b0a493e961a25cc9f8cb33fcc033417360/68747470733a2f2f706f7365722e707567782e6f72672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f762f737461626c65)](https://packagist.org/packages/mcustiel/phiremock-codeception-extension)[![Build Status](https://camo.githubusercontent.com/9734b90f40d44e35fcbe565bca2995c7abe396b5f382689bcad3a383c5a34e09/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mcustiel/phiremock-codeception-extension/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/63399d35bb54ab00bf989d9dcac4e91bcb44476cca8751c847597f1ada2a5090/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mcustiel/phiremock-codeception-extension/?branch=master)[![Monthly Downloads](https://camo.githubusercontent.com/5b93654ff5e93096edf3e5f6634c523c31a1a7605d7cf2291413493ffe973c26/68747470733a2f2f706f7365722e707567782e6f72672f6d6375737469656c2f70686972656d6f636b2d636f646563657074696f6e2d657874656e73696f6e2f642f6d6f6e74686c79)](https://packagist.org/packages/mcustiel/phiremock-codeception-extension)

Installation
============

[](#installation)

### Composer:

[](#composer)

This project is published in packagist, so you just need to add it as a dependency in your composer.json:

```
    "require-dev": {
        "mcustiel/phiremock-codeception-extension": "*"
    },
    "minimum-stability": "dev"
```

> *NOTE*Phiremock uses a dev-master version of react/http to work. Because of this, until reactphp guys tag a new version you will need to set your project's minimum stability to dev.

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

[](#how-to-use)

### Extension

[](#extension)

The extension provides an easy way to start a Phiremock server with configured host, port, debug mode and logs path.

#### Configuration

[](#configuration)

In codeception.yml you will need to enable Phiremock extension and configure it in a proper way:

```
extensions:
    enabled:
        - \Codeception\Extension\Phiremock
    config:
        \Codeception\Extension\Phiremock:
            listen: 127.0.0.1:18080 # defaults to 0.0.0.0:8086
            bin_path: ../vendor/bin # defaults to codeception_dir/../vendor/bin
            logs_path: /var/log/my_app/tests/logs # defaults to codeception's tests output dir
            debug: true # defaults to false
            startDelay: 1 # default to 0
            expectations_path: /my/expectations/path
```

Note: Since Codeception version 2.2.7, extensions configuration can be added directly in the suite configuration file. That will avoid phiremock to be started for every suite.

Phiremock uses annotations internally. To be able to run the extension, the annotations autoloader must be activated. To do this, you must add the next lines in the bootstrap file where you include your composer autoloader:

```
$loader = require APP_ROOT . '/vendor/autoload.php';
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader([$loader, 'loadClass']);
```

Parameters
----------

[](#parameters)

- **listen:** Specifies the interface and port where phiremock must listen for requests
- **bin\_path:** Path where Phiremock "binary" is located
- **logs\_path:** Path where to write the output
- **debug:** Where to write debug data to log files
- **startDelay:** Time to wait after Phiremock was started to start running the tests (used to give time to Phiremock to boot)
- **expectations\_path:** Specifies a directory to search for json files defining expectations to load by default.

### Module

[](#module)

The module allows you to connect to a Phiremock server and to interact with it in a semantic way through the codeception actor in your tests.

#### Configuration

[](#configuration-1)

You need to enable Phiremock module in your suite's configuration file:

```
modules:
    enabled:
        - Phiremock:
            host: 127.0.0.1
            port: 18080
            resetBeforeEachTest: false # if set to true, executes `$I->haveACleanSetupInRemoteService` before each test.
```

#### Use

[](#use)

The module provides the following handy methods to communicate with Phiremock server:

#### expectARequestToRemoteServiceWithAResponse

[](#expectarequesttoremoteservicewitharesponse)

Allows you to setup an expectation in Phiremock, specifying the expected request and the response the server should give for it:

```
    $I->expectARequestToRemoteServiceWithAResponse(
        Phiremock::on(
            A::getRequest()->andUrl(Is::equalTo('/some/url'))
        )->then(
            Respond::withStatusCode(203)->andBody('I am a response')
        )
    );
```

#### haveACleanSetupInRemoteService

[](#haveacleansetupinremoteservice)

Cleans the server of all configured expectations, scenarios and requests history, and reloads expectation files.

```
    $I->haveACleanSetupInRemoteService();
```

#### dontExpectRequestsInRemoteService

[](#dontexpectrequestsinremoteservice)

Cleans all previously configured expectations and requests history.

```
    $I->dontExpectRequestsInRemoteService();
```

#### haveCleanScenariosInRemoteService

[](#havecleanscenariosinremoteservice)

Cleans the state of all scenarios (sets all of them to inital state).

```
    $I->haveCleanScenariosInRemoteService();
```

#### seeRemoteServiceReceived

[](#seeremoteservicereceived)

Allows you to verify that the server received a request a given amount of times. This request could or not be previously set up as an expectation.

```
    $I->seeRemoteServiceReceived(1, A::getRequest()->andUrl(Is::equalTo('/some/url')));
```

#### didNotReceiveRequestsInRemoteService

[](#didnotreceiverequestsinremoteservice)

Resets the requests counter for the verifier in Phiremock.

```
    $I->didNotReceiveRequestsInRemoteService();
```

Use case
--------

[](#use-case)

### Yii2-Curl

[](#yii2-curl)

[Yii2-Curl](https://github.com/linslin/Yii2-Curl) uses phiremock-codeception-extension for functional testing. You can see the configuration for the [extension](https://github.com/linslin/Yii2-Curl/blob/master/codeception.yml) and the [module](https://github.com/linslin/Yii2-Curl/blob/master/tests/functional.suite.yml), as well as how Phiremock is [configured in the tests](https://github.com/linslin/Yii2-Curl/blob/master/tests/functional/httpMockCest.php).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 78% 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 ~42 days

Recently: every ~26 days

Total

19

Last Release

2947d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.5

v1.3.1PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ece848a4abd33cead01bb2656c867ec968006831fd61a85a19fee011bd0f419?d=identicon)[stexaz](/maintainers/stexaz)

---

Top Contributors

[![mcustiel](https://avatars.githubusercontent.com/u/3268370?v=4)](https://github.com/mcustiel "mcustiel (46 commits)")[![andriuspetrauskis](https://avatars.githubusercontent.com/u/2466985?v=4)](https://github.com/andriuspetrauskis "andriuspetrauskis (4 commits)")[![linslin](https://avatars.githubusercontent.com/u/6159031?v=4)](https://github.com/linslin "linslin (4 commits)")[![dewa1t](https://avatars.githubusercontent.com/u/62240484?v=4)](https://github.com/dewa1t "dewa1t (2 commits)")[![drudoi](https://avatars.githubusercontent.com/u/8501350?v=4)](https://github.com/drudoi "drudoi (2 commits)")[![zwirek](https://avatars.githubusercontent.com/u/7045479?v=4)](https://github.com/zwirek "zwirek (1 commits)")

---

Tags

httpcodeceptionmockservertestsextensionexternalacceptancephiremock

### Embed Badge

![Health badge](/badges/phiremock-phiremock-codeception-extension/health.svg)

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

###  Alternatives

[mcustiel/phiremock-codeception-extension

Codeception extension for Phiremock. Allows to stub remote services for HTTP requests.

311.0M5](/packages/mcustiel-phiremock-codeception-extension)[mcustiel/phiremock

A mocker for HTTP and REST services. Full bundle.

151947.1k5](/packages/mcustiel-phiremock)[mcustiel/phiremock-server

A mocker for HTTP and REST services

19843.6k9](/packages/mcustiel-phiremock-server)[mcustiel/phiremock-client

Client library to communicate with Phiremock server

16730.7k4](/packages/mcustiel-phiremock-client)[mcustiel/codeception-http-mock

Extension for HTTP Mock.

1424.3k1](/packages/mcustiel-codeception-http-mock)

PHPackages © 2026

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