Skip to content

v2.0.0

Choose a tag to compare

@dbellettini dbellettini released this 26 Sep 14:12
· 6 commits to main since this release

πŸš€ Major Release: Upgrade to http-batch-contract v2.0

Breaking Changes

  • sendRequestBatch() now returns ResponseBatchInterface instead of array
  • Exceptions are no longer thrown during batch processing, they're captured in results

New Features

  • BatchItem: Implementation of BatchItemInterface for individual request/response pairs
  • ResponseBatch: Implementation of ResponseBatchInterface with full Countable support
  • 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(), and filter()
  • Custom Exceptions: ResponseUnavailableException and ExceptionUnavailableException for 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-contract v2.0
  • PHP 8.4+
  • Guzzle 7.10+

Full Changelog: v1.0.0...v2.0.0