{"id":47907214,"url":"https://github.com/k-kinzal/oas-fake-php","last_synced_at":"2026-04-04T04:56:11.495Z","repository":{"id":345757862,"uuid":"1131090737","full_name":"k-kinzal/oas-fake-php","owner":"k-kinzal","description":"Intercept HTTP requests, validate against OpenAPI schemas, and generate fake responses for testing","archived":false,"fork":false,"pushed_at":"2026-03-25T14:10:56.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T04:56:05.278Z","etag":null,"topics":["api-testing","fake-server","mock-server","openapi","openapi-mock","php","php-testing","php-vcr","testing"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/k-kinzal/oas-fake-php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-kinzal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-01-09T13:11:26.000Z","updated_at":"2026-03-22T05:16:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/k-kinzal/oas-fake-php","commit_stats":null,"previous_names":["k-kinzal/oas-fake-php"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/k-kinzal/oas-fake-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Foas-fake-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Foas-fake-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Foas-fake-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Foas-fake-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-kinzal","download_url":"https://codeload.github.com/k-kinzal/oas-fake-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Foas-fake-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31388169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-testing","fake-server","mock-server","openapi","openapi-mock","php","php-testing","php-vcr","testing"],"created_at":"2026-04-04T04:56:09.513Z","updated_at":"2026-04-04T04:56:11.473Z","avatar_url":"https://github.com/k-kinzal.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OAS Fake PHP\n\n[![CI](https://github.com/k-kinzal/oas-fake-php/actions/workflows/ci.yml/badge.svg)](https://github.com/k-kinzal/oas-fake-php/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PHP Version](https://img.shields.io/badge/PHP-8.0%2B-blue.svg)](https://www.php.net/)\n\nOpenAPI 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.\n\n## Features\n\n- Automatic fake response generation from OpenAPI schema definitions\n- Request/response validation against the OpenAPI schema\n- Custom response stubs and callbacks per operation\n- Declarative server classes with handler methods mapped by `operationId`\n- Three operating modes: FAKE, RECORD, REPLAY\n- PSR-15 middleware support\n\n## Requirements\n\n- PHP 8.0+\n- ext-curl\n\n## Installation\n\n```bash\ncomposer require --dev k-kinzal/oas-fake-php\n```\n\n## Usage\n\n### Basic\n\nDefine a server pointing to your OpenAPI schema and start intercepting:\n\n```php\nuse OasFake\\OasFake;\nuse OasFake\\Server;\n\nfinal class PetStoreServer extends Server\n{\n    protected static string $SCHEMA = __DIR__ . '/openapi.yaml';\n}\n\n// Start intercepting HTTP requests\n$server = OasFake::start(PetStoreServer::class);\n\n// All HTTP requests now return responses generated from the schema\n$client = new GuzzleHttp\\Client(['base_uri' =\u003e 'https://petstore.example.com']);\n$response = $client-\u003eget('/pets/1');\n\n// Stop intercepting\nOasFake::stop();\n```\n\n### Custom Responses\n\nOverride responses for specific operations using the configure callback:\n\n```php\nuse OasFake\\OasFake;\nuse OasFake\\Handler;\n\n$server = OasFake::start(PetStoreServer::class, fn ($s) =\u003e $s\n    -\u003ewithResponse('listPets', 200, [['id' =\u003e 1, 'name' =\u003e 'Buddy']])\n    -\u003ewithCallback('createPet', function ($request, $response) {\n        $body = json_decode((string) $request-\u003egetBody(), true);\n        return new \\GuzzleHttp\\Psr7\\Response(201, [], json_encode([\n            'id' =\u003e 42,\n            'name' =\u003e $body['name'],\n        ]));\n    })\n    -\u003ewithHandler('deletePet', Handler::status(204))\n);\n```\n\n### Declarative Server\n\nPublic methods on a `Server` subclass are automatically registered as handlers, matched by `operationId`:\n\n```php\nuse OasFake\\Server;\nuse GuzzleHttp\\Psr7\\Response;\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Message\\ServerRequestInterface;\n\nfinal class PetStoreServer extends Server\n{\n    protected static string $SCHEMA = __DIR__ . '/openapi.yaml';\n\n    public function listPets(ServerRequestInterface $request, ?ResponseInterface $response): ResponseInterface\n    {\n        return new Response(200, ['Content-Type' =\u003e 'application/json'], json_encode([\n            ['id' =\u003e 1, 'name' =\u003e 'Buddy'],\n        ]));\n    }\n\n    #[\\OasFake\\Route(method: 'DELETE', path: '/pets/{petId}')]\n    public function removePet(ServerRequestInterface $request, ?ResponseInterface $response): ResponseInterface\n    {\n        return new Response(204);\n    }\n}\n```\n\n### Configuration\n\n```php\nuse OasFake\\OasFake;\nuse OasFake\\Mode;\n\n$server = OasFake::start(PetStoreServer::class, fn ($s) =\u003e $s\n    -\u003ewithMode(Mode::RECORD)  // or -\u003ewithMode('record')\n    -\u003ewithCassettePath('./fixtures/cassettes')\n    -\u003ewithRequestValidation(false)\n    -\u003ewithResponseValidation(false)\n    -\u003ewithFakerOptions(['alwaysFakeOptionals' =\u003e true, 'minItems' =\u003e 2, 'maxItems' =\u003e 5])\n    -\u003ewithMiddleware(new MyMiddleware())\n);\n```\n\nAll settings can also be overridden via environment variables:\n\n```bash\nOAS_FAKE_MODE=record OAS_FAKE_VALIDATE_REQUESTS=false composer test\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-kinzal%2Foas-fake-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-kinzal%2Foas-fake-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-kinzal%2Foas-fake-php/lists"}