public function makeHttpRequest(...)
{
// just define the basic filename, the file extension will be added
// based on the configured storage type ('.yaml', '.json')
$this->httpRecorderService->setRecordingFile('your-recording-file');
try {
$this->client->call(...);
} finally {
// stop recording (=turn off VCR client) after the request,
// no matter if it succeeds or fails
register_shutdown_function(function () {
$this->httpRecorderService->stopRecording();
});
}
}
use TurbineKreuzberg\Shared\HttpRecorder\HttpRecorderConstants;
/**
* MODES:
* To enable the usage of http recorder, set the mode.
* - To just record requests and responses, use mode HttpRecorderConstants::MODE_RECORD
$config[HttpRecorderConstants::MODE] = HttpRecorderConstants::MODE_RECORD;
* - To just replay recorded requests and responses, use mode HttpRecorderConstants::MODE_REPLAY
* If no recording exists, the first request (and response) will be recorded
$config[HttpRecorderConstants::MODE] = HttpRecorderConstants::MODE_REPLAY;
*
* LIBRARY HOOKS:
* By default all library hooks are enabled.
* But you can also specifically enable only some hooks, e.g. 'soap':
$config[HttpRecorderConstants::VCR_LIBRARY_HOOKS] = [
'soap',
];
* For more details, see https://php-vcr.github.io/documentation/configuration/#library-hooks
*
* RECORDING PATH:
* By default, recordings are stored and read from /tmp
* To use recordings from a different folder, set HttpRecorderConstants::VCR_CASSETTE_PATH to that path.
$config[HttpRecorderConstants::VCR_CASSETTE_PATH] = APPLICATION_ROOT_DIR . '/your/custom/path/for/vcr/recordings';
*
* STORAGE TYPE:
* By default, recordings are stored in JSON format ('json').
* To use yaml format, set storage type to 'yaml':
$config[HttpRecorderConstants::VCR_STORAGE_TYPE] = 'yaml';
* For more details, see https://php-vcr.github.io/documentation/configuration/#storage
*
* REQUEST MATCHERS:
* Requests are matched by different criteria. By default, these request matchers are used:
$config[HttpRecorderConstants::VCR_REQUEST_MATCHERS] = [
'method',
'url',
'host',
];
* You can create your own request matchers and use them as callbacks
* For more details, see https://php-vcr.github.io/documentation/configuration/#request-matching
*
* ALLOW/DENY LISTS FOR PATHS TO INTERCEPT:
* By default, there is an allow list with 'vendor/guzzle':
$config[HttpRecorderConstants::VCR_ALLOW_LIST] = [
'vendor/guzzle',
];
* The deny list is empty by default:
$config[HttpRecorderConstants::VCR_DENY_LIST] = [];
* For more details, see https://php-vcr.github.io/documentation/configuration/#white--and-blacklisting-paths
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.