PHPackages                             mcustiel/codeception-http-mock - 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. mcustiel/codeception-http-mock

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

mcustiel/codeception-http-mock
==============================

Extension for HTTP Mock.

v0.7(9y ago)1424.3k7[2 issues](https://github.com/mcustiel/codeception-http-mock/issues)1GPL-3.0+PHPPHP &gt;=5.4CI failing

Since Nov 11Pushed 9y ago3 watchersCompare

[ Source](https://github.com/mcustiel/codeception-http-mock)[ Packagist](https://packagist.org/packages/mcustiel/codeception-http-mock)[ RSS](/packages/mcustiel-codeception-http-mock/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (4)Dependencies (9)Versions (5)Used By (1)

codeception-http-mock
=====================

[](#codeception-http-mock)

This Codeception Extension allows developers and testers to use HttpMock to mock external services when running codeception tests.

codeception-http-mock runs an instance of http-mock before your tests run so they can mock external services. After the tests are finished it will close the connection and turn http-mock off.

See also
--------

[](#see-also)

- [http-mock library](https://github.com/InterNations/http-mock)

Note
----

[](#note)

http-mock is a nice application but it is very simple and lacks a lot of functionality. If you need a more complete application to mock and stub remote services, please give Phiremock a try. [Phiremock](https://github.com/mcustiel/phiremock) also has a nice [codeception extension](https://github.com/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": {
        // ...
        "mcustiel/codeception-http-mock": "*"
    }
```

If you want to access directly to this repo, adding this to your composer.json should be enough:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mcustiel/codeception-http-mock"
        }
    ],
    "require": {
        "mcustiel/codeception-http-mock": "dev-master"
    }
}
```

Or just download the release and include it in your path.

Configuration Example
---------------------

[](#configuration-example)

### Extension

[](#extension)

```
# codeception.yml
extensions:
    enabled:
        - Codeception\Extension\HttpMock
    config:
        Codeception\Extension\HttpMock:
            port: 18080 # defaults to http-mock default port
            host: name.for.my.server # defaults to http-mock default host
```

### Module

[](#module)

```
# acceptance.yml
modules:
    enabled:
        - HttpMock
```

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

[](#how-to-use)

### Prepare your application

[](#prepare-your-application)

First of all, configure your application so when it is being tested it will replace its external services with http-mock. For instance, if you make some requests to a REST service located under , replace that url in configuration with the host yoy set up in http-mock extension configuration.

### Write your tests

[](#write-your-tests)

```
// YourCest.php
class YourCest extends \Codeception\TestCase\Test
{
    // tests
    public function tryToTest(\AcceptanceTester $I)
    {
        $I->expectRequest()->when()
                ->methodIs('GET')
                ->pathIs('/foo')
            ->then()
                ->body('mocked body')
            ->end();
        $I->doNotExpectAnyOtherRequest();
        $response = file_get_contents('http://localhost:28080/foo');
        $I->assertEquals('mocked body', $response);
    }
}
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.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 ~146 days

Total

4

Last Release

3443d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d9b3ff93206038debfa1f16a11bbfc10fca9b2f4ddfdafa00e27365d290cf0d?d=identicon)[mcustiel](/maintainers/mcustiel)

---

Top Contributors

[![mcustiel](https://avatars.githubusercontent.com/u/3268370?v=4)](https://github.com/mcustiel "mcustiel (13 commits)")[![dzoeteman](https://avatars.githubusercontent.com/u/614371?v=4)](https://github.com/dzoeteman "dzoeteman (1 commits)")

---

Tags

httpcodeceptionmockextensionmodulemock external serviceshttp mock

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mcustiel-codeception-http-mock/health.svg)

```
[![Health](https://phpackages.com/badges/mcustiel-codeception-http-mock/health.svg)](https://phpackages.com/packages/mcustiel-codeception-http-mock)
```

###  Alternatives

[mcustiel/phiremock-codeception-extension

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

311.1M6](/packages/mcustiel-phiremock-codeception-extension)[site5/phantoman

The Codeception extension for automatically starting and stopping PhantomJS when running tests.

481.1M17](/packages/site5-phantoman)[docler-labs/codeception-slim-module

Codeception Module for Slim framework.

13206.0k1](/packages/docler-labs-codeception-slim-module)

PHPackages © 2026

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