Schema-driven universal API mock server with OpenAPI ingestion, stateful storage, and chaos latency simulation in pure PHP 8.2+.
eidcloud-api-mock is a zero-dependency, ultra-fast mock server and API sandbox built for modern microservices and front-end prototyping. It parses OpenAPI 3.0 / 3.1 & Swagger 2.0 specifications on the fly, produces realistic synthetic payloads (matching UUIDs, emails, RFC3339 timestamps, URIs, and regex constraints), persists dynamic state across calls, and injects controlled network latency and chaos errors for resilience testing.
flowchart TD
A["OpenAPI 3.0 / 3.1 & Swagger 2.0 (JSON/YAML)"] --> B["OpenApiParser"]
B --> C["MockServer Router & Engine"]
C --> D{"Stateful Storage (MemoryStore)"}
C --> E{"Chaos & Latency Simulator"}
D -->|CRUD Operations| F["Realistic Synthetic Payloads (PayloadFaker)"]
E -->|Delay + 5xx Injections| G["Client HTTP Response"]
F --> G
- Zero External Dependencies: Operates exclusively on pure standard PHP 8.2+, requiring no composer packages or C extensions.
- Specification Ingestion: Ingests both JSON and YAML OpenAPI 3.0, 3.1, and Swagger 2.0 documents with full
$refresolution. - Realistic Synthetic Payloads: Intelligent faker heuristics for UUIDs (
uuid), email (email), dates (date-time), web URLs (uri), IP addresses (ipv4), enum constraints, and semantic names. - Dynamic Stateful Storage: Memory-backed stateful store. Creating an entity with
POST /usersimmediately reflects in subsequent calls toGET /users/{id}orGET /users. - Chaos Engineering & Resilience Simulation: Injects realistic latency jitter (
--delay=150ms) and intermittent HTTP error spikes (--error-rate=15%triggering 500, 502, 503, 504). - Built-in HTTP Micro-Server: Direct integration with PHP's built-in web server through
bin/eidcloud-mock serve. - Static Fixture Generator: Generate complete static JSON mock trees with
bin/eidcloud-mock generate --out=./mock_data/.
Clone repository:
git clone https://github.com/eidcloud/eidcloud-api-mock.git
cd eidcloud-api-mockOr install via Composer:
composer require eidcloud/api-mockServe an OpenAPI specification with 150ms delay and 10% chaos failure rate:
php bin/eidcloud-mock serve examples/openapi.json --port=8080 --delay=150ms --error-rate=10%Test an endpoint using curl:
# 1. Create a user (Stateful)
curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{"name": "Eng. Shadi AL-Hasan", "email": "shadi@eidcloud.io", "role": "admin"}'
# 2. Retrieve user
curl http://localhost:8080/users/1Export synthetic JSON fixtures for frontend mock directories or CI staging:
php bin/eidcloud-mock generate examples/openapi.json --out=./mock_data/ --jsonInspect registered endpoints and check schema compatibility:
php bin/eidcloud-mock validate examples/openapi.json<?php
use EidCloud\ApiMock\MockServer;
use EidCloud\ApiMock\Simulator\ChaosSimulator;
require_once __DIR__ . '/vendor/autoload.php';
// Initialize with latency and chaos simulation
$chaos = new ChaosSimulator(delayMs: 120, errorRate: 0.05);
$server = new MockServer('openapi.json', null, $chaos);
// Handle HTTP requests programmatically
$response = $server->handle('GET', '/users/1');
echo "HTTP Status: " . $response['statusCode'] . "\n";
print_r($response['body']);Run the zero-dependency test suite:
php tests/run_tests.phpEng. MHD. Shadi AL-Hasan
- Role: Executive CTO & Enterprise Solutions Architect
- Email: mhd.shadi.alhasan@gmail.com
- Phone / WhatsApp: +963934005922
- Location: Damascus, Syria
- GitHub: shadialhasan
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2026 MHD. Shadi AL-Hasan. All rights reserved.