Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf

[*.php]
indent_size = 4
indent_style = space
insert_final_newline = true
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@
API for "the software to mock third-party responses" to include in your application's API tests.
 
 

## Use Proxy / Automatic Mode
To automatically forward requests to the API mock there is the possibility to use a `HandlerStack` for `Guzzle`.
The `HandlerStack` checks if a request has already been saved and if not,
the request will be sent to the correct host and then the response will be cached,
so that the next time a request will be sent to the API mock, and the cached response will be returned.

```php
<?php
//...
$apiMockClient = new \GuzzleHttp\Client([/*...*/]);
$apiMock = new \ApiMock\Core\ApiMock($apiMockClient);
$proxyStack = new \ApiMock\Proxy\ProxyStack($apiMock);

$myDefaultClient = new \GuzzleHttp\Client([
/*...*/
'handler' => $proxyStack,
]);

// Will be sent against example.org
$myDefaultClient->get('https://example.org', []);
// Will be sent against API Mock
$myDefaultClient->get('https://example.org', []);
```


## <a id="Troubleshooting" href="#Troubleshooting">Troubleshooting</a>
---
#### I used a requestKey, but the `ApiMock::getClientRequest()` gets a 404/null
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=7.4",
"guzzlehttp/guzzle": "^6.3",
"ext-json": "*"
},
Expand Down
Loading