PHPackages                             aldidigitalservices/php-mock-collector - 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. aldidigitalservices/php-mock-collector

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

aldidigitalservices/php-mock-collector
======================================

A simple Mockserver in PHP that enables you to get the request that was send to the Mockserver (e.g. for Testing)

1.4.0(1y ago)010.4k↓50%3[1 PRs](https://github.com/ALDIDigitalServices/phpMockCollector/pulls)MITPHPPHP ~7.4 || ^8.0

Since Aug 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/ALDIDigitalServices/phpMockCollector)[ Packagist](https://packagist.org/packages/aldidigitalservices/php-mock-collector)[ RSS](/packages/aldidigitalservices-php-mock-collector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (0)

\#How to use: Install phpMockServer using composer

```
composer require aldidigitalservices/php-mock-collector

```

Create a new instance of phpMockServer and run the run methode:

```
require_once 'vendor/autoload.php';

$ms = new \ALDIDigitalServices\pms\phpMockServer(__DIR__."/mocks");
$ms->run();
```

After that you can define mocks in the mockfolder (By default it is ../mocks based from the phpMockServer.php file but can be configured by the constructor):

If you want to create a mock for /hello/world create the folders /hello/world and place a mock.json in it.

In this json file you can define different methodes (GET, POST, PUT, ...) and define the static response.

If you need it more flexible you can define a customcallback class implementing the customCallbackInterface and place it in a php file named by your classname in the mock folder and add the customCallback setting in the mock.json (see /hellophp/mock.json)

\#Configure the Mocks You can configure the mock by the following options:

```
body: could be a string or an array. The array would be json encoded
header: is a array of headers that should be send to the client (key => value)
httpcode: The responecode that is returned by the mock. e.g. 404
latency: This latency is added to the execution time. (Value in seconds)
customCallback: the Classname of the customCallback that should be used to create the response. This option is exclusiv so the other options ( exept rules will not apply)
ProxyPath: A URL to proxy the request to
rules: An array of rules that has to apply for this response. See rules

```

On top of this you can define wildcard routes. For that you have to place the configuration for the methode into an object with an path element that holds an regex:

```
{
  "path": [{
    "route": "{{regex}}",
    "GET": [
      {
        ...
      }
    ]
  }]
}
```

\##rules You can configure rules like this:

```
param: is a list of key values that has to be set. Value can be *.
bodyregex: a list of regex that would be performed on the body content
preselection: you can define a preseletion upfront and check with this rule if the preselection match the value that was set by preselection

```

You can implement additional rules by implementing the ruleImplementationInterface.

\#Integrations ##Codeception You can use the Mock Request inside of codeceptiontests by adding the MockAwaitModule to your Testsuite:

```
actor: ApiTester
modules:
    enabled:
        - \Helper\Api
        - REST:
            url: https://jsonplaceholder.typicode.com/
            depends: PhpBrowser
        - \ALDIDigitalServices\pms\integrations\codeception\MockAwait
```

Include Payload validation in external Tests
============================================

[](#include-payload-validation-in-external-tests)

For every request to the mock server you can await the payload + additional data with the awaitcall function in clientDemo.php (This has to be transfered to a codeception module/helper). You can define a path , a methode (GET, POST, PUT, ...) and the timeout to wait for the response.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 75.8% 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 ~126 days

Recently: every ~198 days

Total

10

Last Release

596d ago

PHP version history (2 changes)1.0.0PHP ~7.4

1.4.0PHP ~7.4 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![DanielHansmannAldi](https://avatars.githubusercontent.com/u/83207188?v=4)](https://github.com/DanielHansmannAldi "DanielHansmannAldi (50 commits)")[![zeetabit](https://avatars.githubusercontent.com/u/10453056?v=4)](https://github.com/zeetabit "zeetabit (8 commits)")[![alfredbez](https://avatars.githubusercontent.com/u/1001186?v=4)](https://github.com/alfredbez "alfredbez (2 commits)")[![michael-schmetter](https://avatars.githubusercontent.com/u/24694463?v=4)](https://github.com/michael-schmetter "michael-schmetter (2 commits)")[![profuel](https://avatars.githubusercontent.com/u/3640652?v=4)](https://github.com/profuel "profuel (2 commits)")[![christianankert](https://avatars.githubusercontent.com/u/126254184?v=4)](https://github.com/christianankert "christianankert (1 commits)")[![christianlerch](https://avatars.githubusercontent.com/u/36992306?v=4)](https://github.com/christianlerch "christianlerch (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aldidigitalservices-php-mock-collector/health.svg)

```
[![Health](https://phpackages.com/badges/aldidigitalservices-php-mock-collector/health.svg)](https://phpackages.com/packages/aldidigitalservices-php-mock-collector)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)

PHPackages © 2026

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