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.6k1[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 yesterday

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

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

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

2675d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16067161?v=4)[Nassim](/maintainers/Kirouane)[@Kirouane](https://github.com/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

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[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.7k16.4k79](/packages/elgg-elgg)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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