PHPackages                             kirouane/imposter - 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. kirouane/imposter

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

kirouane/imposter
=================

API mock for PHPUnit

1.0.0(7y ago)512.5k1[1 PRs](https://github.com/Kirouane/imposter/pulls)MITPHPPHP &gt;=7.0

Since Mar 7Pushed 6y ago2 watchersCompare

[ Source](https://github.com/Kirouane/imposter)[ Packagist](https://packagist.org/packages/kirouane/imposter)[ Docs](https://github.com/Kirouane/imposter)[ RSS](/packages/kirouane-imposter/feed)WikiDiscussions master Synced 1mo ago

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

[![Travis](https://camo.githubusercontent.com/d3731bec042b253dc958273a1d3efd66ba1f1b7263897c37f3856e8d10597984/68747470733a2f2f7472617669732d63692e636f6d2f4b69726f75616e652f696d706f737465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Kirouane/imposter.svg?branch=master)[![Coverage Status](https://camo.githubusercontent.com/d7bb91b5c2049ad5a6a145cc703b97f7c20ad08a1780c59c6c29c6080d0b5df0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4b69726f75616e652f696d706f737465722f62616467652e737667)](https://coveralls.io/github/Kirouane/imposter?branch=master)

Imposter
========

[](#imposter)

Imposter is a php library that used to serve http stubs and mocks.

Here is an example to emphasize how is simple to mock an HTTP endpoint with this library in PHPUnit.

```
namespace Imposter;

use PHPUnit\Framework\TestCase;

/**
 * Class ScenarioTest
 * @package Imposter
 */
class ReadMeTest extends TestCase
{
    /**
     * @test
     *
     */
    public function match()
    {
        ImposterFactory::get()->mock(8081)
            ->withPath('/users/1')
            ->withMethod('POST')
            ->returnBody('{"response" :"okay"}')
            ->once()
            ->send();

        $client   = new \GuzzleHttp\Client();
        $response = $client->post('http://localhost:8081/users/1')->getBody()->getContents();
        self::assertSame($response, '{"response" :"okay"}');
    }

    public function tearDown()
    {
        ImposterFactory::get()->close();
    }
}
```

Install
=======

[](#install)

`composer require kirouane/imposter --dev`

Features
========

[](#features)

Display logs
------------

[](#display-logs)

In case of the HTTP request doesn't match any mock, you can find out the reason here

Below, you can see what the logs page looks like.

[![Logs](doc/log.png)](doc/log.png)

PHPUnit Asserter
----------------

[](#phpunit-asserter)

Imposter Library uses PHPunit asserters to match HTTP requests with the mocks you create.

Example :

```
namespace Imposter;

use PHPUnit\Framework\TestCase;

/**
 * Class ScenarioTest
 * @package Imposter
 */
class ReadMeTest extends TestCase
{
    /**
     * @test
     */
    public function match()
    {
        ImposterFactory::get()->mock(8081)
            ->withPath('/users/1')
            ->withMethod(new RegularExpression('/POST|PUT/'))
            ->returnBody('{"response" :"okay"}')
            ->twice()
            ->send();

        $client   = new \GuzzleHttp\Client();
        $response = $client->post('http://localhost:8081/users/1')->getBody()->getContents();
        self::assertSame($response, '{"response" :"okay"}');

        $response = $client->put('http://localhost:8081/users/1')->getBody()->getContents();
        self::assertSame($response, '{"response" :"okay"}');
    }

    public function tearDown()
    {
        ImposterFactory::get()->close();
    }

}
```

Proxies
-------

[](#proxies)

Not implemented yet

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.5% 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

Unknown

Total

1

Last Release

2629d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3df43747132f114d241a3edbe7f4f89174b19b0ad853a29bd7789cdb328b2e62?d=identicon)[Kirouane](/maintainers/Kirouane)

---

Top Contributors

[![Kirouane](https://avatars.githubusercontent.com/u/16067161?v=4)](https://github.com/Kirouane "Kirouane (60 commits)")[![nassimkirouane](https://avatars.githubusercontent.com/u/10706013?v=4)](https://github.com/nassimkirouane "nassimkirouane (8 commits)")[![codisart](https://avatars.githubusercontent.com/u/1767237?v=4)](https://github.com/codisart "codisart (3 commits)")

---

Tags

apihttpmockphpphpunitstub

### Embed Badge

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

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

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.4k37.3k](/packages/matomo-matomo)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)

PHPackages © 2026

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