Download the PHP package k-kinzal/oas-fake-php without Composer
On this page you can find all versions of the php package k-kinzal/oas-fake-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package oas-fake-php
OAS Fake PHP
OpenAPI schema-driven fake API server for PHP testing. Define your API contract once, and automatically get a working fake server that generates valid responses, validates requests, and catches schema violations in your tests.
Features
- Automatic fake response generation from OpenAPI schema definitions
- Request/response validation against the OpenAPI schema
- Custom response stubs and callbacks per operation
- Declarative server classes with handler methods mapped by
operationId - Three operating modes: FAKE, RECORD, REPLAY
- PSR-15 middleware support
Public API Surface
The primary user-facing entry points are OasFake, Server, Schema, FakeDataContext, FakeRequest, FakeResponse, Handler, Route, Mode, the documented exception types, and Validator for standalone validation. Pipeline and support classes such as Interceptor, ServerRegistry, Converter, OperationLookup, HandlerMap, and ParameterFaker are available under the same namespace for advanced use.
Requirements
- PHP 8.0 - 8.5
- ext-curl
Installation
Usage
Basic
Define a server pointing to your OpenAPI schema and start intercepting:
OasFake::stop() stops every running fake server. To stop only one server while leaving other registered servers active, pass the server instance: OasFake::stop($server) or $server->stop().
Custom Responses
Override responses for specific operations using the configure callback:
Declarative Server
Public handler methods on a Server subclass are automatically registered, matched by operationId:
Declarative handler methods should accept ServerRequestInterface as their first parameter and return a ResponseInterface. Public helper methods without that handler signature are ignored.
Configuration
Mode::RECORD records OasFake's generated or custom responses to cassettes for deterministic replay. It does not proxy requests to a real upstream API.
All settings can also be overridden via environment variables:
License
MIT
All versions of oas-fake-php with dependencies
canvural/php-openapi-faker Version ^2.0
cebe/php-openapi Version 1.7.0
guzzlehttp/psr7 Version ^2.6
league/openapi-psr7-validator Version ^0.18
php-vcr/php-vcr Version ^1.8