Features
- Automatic Endpoint Registration
- Scans the
responses/ folder and automatically
registers endpoints based on the directory structure.
- The API base path can be configured via environment
variables.
- Supports dynamic parameter parsing such as
GET users/{group}/{limit}.
- Dynamic Response Loading
.json → Returns JSON response.
.txt → Returns plain text response.
- Polling Support
- If multiple files such as
1.json,
2.json, etc., are prepared, responses will change based
on request count.
- Polling is executed per client, and can be reset via
POST: /reset_polling.
- Custom Responses
- Use query parameter
mock_response to dynamically
switch responses. Example:
GET /users?mock_response=success → Returns
responses/users/get/success.json.
- Use
mock_content_type to specify response
Content-Type. Example:
GET /others?mock_response=xml&mock_content_type=application/xml
→ Returns responses/others/get/xml.txt as XML
format.
- Error Responses
- Define error responses such as
responses/errors/404.json.
- Response Delay
- Specify
"mockDelay": 1000 (1 second) in a JSON
response file to delay the response.
- Custom Hooks
- Register custom hooks for each method + endpoint request to
override response content. Example:
GET /users request
can be handled by a custom hook
hooks/get_users.php.
- OpenAPI Schema Support
- Equipped with a function to automatically generate OpenAPI 3.0
schema based on JSON responses.
- The
example items in the schema are also
appropriately trimmed and padded to avoid excess response data.
- It uses
opis/json-schema for validation and
automatically checks for schema consistency.
- Logging
request.log stores request details (headers, query,
body).
response.log stores response details.
auth.log stores authentication failures, and
error.log stores generic errors.
- All logs are linked by a request ID for traceability.
- Validation errors during automatic OpenAPI schema generation can
be tracked in
validation-error.log.
- Configuration via Environment Variables
- Uses
vlucas/phpdotenv to read environment
variables.
.env can define server settings such as
PORT, base API path, temporary file storage
(cookies.txt, etc.), and logging paths.
- Simple authentication via
API_KEY and
CREDENTIAL.