v2.0.0
π Major Release: Upgrade to http-batch-contract v2.0
Breaking Changes
- sendRequestBatch() now returns
ResponseBatchInterfaceinstead of array - Exceptions are no longer thrown during batch processing, they're captured in results
New Features
- BatchItem: Implementation of
BatchItemInterfacefor individual request/response pairs - ResponseBatch: Implementation of
ResponseBatchInterfacewith fullCountablesupport - Exception Handling: Network/client errors are now part of the batch results instead of interrupting the entire batch
- Rich Utility Methods: Access to
isCompleteSuccess(),hasAnyFailures(),getSuccessfulResults(),getFailedResults(), andfilter() - Custom Exceptions:
ResponseUnavailableExceptionandExceptionUnavailableExceptionfor type-safe error handling
Migration Guide
Before (v1.x):
try {
$responses = $client->sendRequestBatch($requests);
foreach ($responses as $response) {
// Process response
}
} catch (\Exception $e) {
// Handle batch failure
}After (v2.0):
$batch = $client->sendRequestBatch($requests);
if ($batch->isCompleteSuccess()) {
foreach ($batch->getResults() as $item) {
$response = $item->getResponse();
// Process response
}
} else {
// Handle mixed results
foreach ($batch->getSuccessfulResults() as $item) {
// Process successful responses
}
foreach ($batch->getFailedResults() as $item) {
$exception = $item->getException();
// Handle individual failures
}
}Dependencies
- Requires
friendsofouro/http-batch-contractv2.0 - PHP 8.4+
- Guzzle 7.10+
Full Changelog: v1.0.0...v2.0.0