You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Gemini CLI Instructional Context: PHP OpenAPI Mock Server
2
+
3
+
This document provides foundational context and instructions for AI agents interacting with the `php-openapi-mock-server` codebase.
4
+
5
+
## Project Overview
6
+
**PHP OpenAPI Mock Server** is a high-performance, lightweight, zero-Docker mock server built with the Mezzio framework. It serves mock data based on OpenAPI 3.x specifications (JSON or YAML) and is designed for rapid prototyping and CI environments.
7
+
8
+
-**Type:** PHP Web Application (PSR-15 Middleware Stack)
9
+
-**Framework:**[Mezzio](https://docs.mezzio.dev/)
10
+
-**Core Libraries:**
11
+
-`league/openapi-psr7-validator`: For request and response validation against OpenAPI specs.
12
+
-`devizzent/cebe-php-openapi`: For parsing OpenAPI specifications.
-`webmozart/assert`: For strict runtime type verification.
15
+
-**Language:** PHP 8.3+ (Strict Types enabled)
16
+
17
+
## Architecture & Logic
18
+
The application operates primarily through a series of PSR-15 middlewares and a stateless service registry:
19
+
1.**`ForceMockActiveMiddleware`**: Ensures the mock server is active by default by setting the `X-OpenApi-Mock-Active` header.
20
+
2.**`OpenApiMockMiddleware`**: The core logic that intercepts requests, validates them, and returns faked responses. It handles all documentation routes (`/`, `/openapi.yaml`) by passing them to the standard routing stack.
21
+
3.**`FakerRegistry`**: A central, stateless registry for all mock generation services.
22
+
4.**Type-Safe Enums**: Extensive use of PHP 8.3 Enums for `FakerType`, `FakerContext`, `HttpMethod`, and `RequestErrorType` to eliminate magic strings and harden type safety.
23
+
5.**Factories:** Found in `src/Factory/` and use **PSR-17 interfaces** (`ResponseFactoryInterface`, `StreamFactoryInterface`) for dependency injection.
24
+
25
+
## Building and Running
26
+
27
+
### Development Server
28
+
Run the built-in PHP server:
29
+
```bash
30
+
php -S localhost:8080 -t public
31
+
```
32
+
33
+
### Docker (FrankenPHP)
34
+
Optimized [FrankenPHP](https://frankenphp.dev/) environment with **Hot-Reload** support:
35
+
```bash
36
+
docker compose up -d
37
+
```
38
+
39
+
### Environment Variables
40
+
-`OPENAPI_SPEC`: Path or URL to the OpenAPI specification file (Default: `data/openapi.yaml`).
41
+
42
+
### Key Composer Scripts
43
+
-`composer test`: Runs the full Codeception test suite (**95 tests passing**).
0 commit comments