Releases: Thavarshan/fetch-php
Releases · Thavarshan/fetch-php
v2.0.6
Added
- Added
withQueryParameter()method for adding a single query parameter - Added
withJson()method as a convenient way to set JSON request bodies - Added
withFormParams()andwithMultipart()helper methods for form submissions - Added
configurePostableRequest()helper method to standardize request body handling
Changed
- Enhanced
withBody()method to support multiple content types (JSON, form-encoded, multipart) - Improved
post()andput()methods to properly handle different content types - Improved retry mechanism with exponential backoff and jitter for better reliability
- Enhanced error handling to be more selective about which errors trigger retries
Fixed
- Fixed query parameter handling to properly merge with existing parameters instead of overwriting
- Fixed URL construction in
getFullUri()to correctly append query parameters - Fixed retry logic to perform exactly the specified number of retries (not one extra)
- Fixed duplicate implementation of
isRetryableError()method - Fixed retry failure detection to properly identify the last retry attempt
Full Changelog: 2.0.5...2.0.6
v2.0.5
Added
- Added the following utility methods to
ClientHandler:getOptions(): Retrieve the full request options array.getHeaders(): Retrieve the headers array from the request options.hasHeader(string $header): bool: Check if a specific header is set in the request.hasOption(string $option): bool: Check if a specific option is set in the request.
Full Changelog: 2.0.4...2.0.5
v2.0.4
Added
- Added support for setting a single request header via
withHeader()method inClientHandler. - Introduced new methods in
ClientHandlerinterface:withToken(string $token): selfwithAuth(string $username, string $password): selfwithHeader(string $header, mixed $value): self
- Added
laravel/pintas a development dependency.
Changed
- Updated package version in
composer.jsonfrom2.0.3to2.0.4. - Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in #13
- Update README fixing syntax error by @tresbach in #14
Fixed
- Restored required dependencies
jerome/matrixandpsr/http-messagetocomposer.json.
New Contributors
Full Changelog: 2.0.3...2.0.4
v2.0.3
Added
- Support all PHP
8.xversions
Changed
- Updated dependencies
- Updated dev dependencies
Full Changelog: 2.0.2...2.0.3
v2.0.2
Added
- Add Laravel Pint by @patinthehat in #8
- Add
isAsyncmethod toClientHandler
Changed
- Update
asyncmethod to accept arguments
New Contributors
- @patinthehat made their first contribution in #8
Full Changelog: 2.0.1...2.0.2
v2.0.1
Changed
- Refactor
withBodymethod inClientHandlerto only accept array arguments and encode given arguments to json string when called - Update documentation and fix typos
v2.0.0
Added
- VitePress Documentation: Introduced a new VitePress documentation site, including comprehensive API reference, examples, and guides. The site is accessible under the
./docs/directory and deployable on Netlify. - Async Functionality: Introduced a new async functionality using
async()function powered by PHP Fibers for true asynchronous operations. This provides a modern, JavaScript-likeasync/awaitsyntax for handling non-blocking requests. - Fluent API for HTTP Requests: Added support for a fluent, chainable API inspired by Laravel’s HTTP client. Methods like
withHeaders(),withBody(),withToken(), and others allow for more intuitive and flexible request building. - Task Lifecycle Management: Introduced
Matrix-powered task lifecycle management, allowing tasks to be paused, resumed, canceled, and retried for asynchronous requests. - Retry Logic with Exponential Backoff: Added customizable retry logic for both synchronous and asynchronous requests, allowing for retries with exponential backoff in case of network failures.
Changed
- Refactor of
fetch()Function: Refactored the corefetch()function to support both synchronous and asynchronous requests seamlessly. Now supports direct chaining of promises withthen()andcatch()for async requests. - Improved Error Handling: Enhanced error handling to provide better control over exceptions during both sync and async requests. Introduced customizable error handlers and improved promise rejection management.
- Response Class Overhaul: The
Responseclass has been revamped to better handle different response formats, including JSON, text, binary data (array buffer), and streams. This improves the handling of diverse response types. - Expanded Guzzle Configuration Options: The package now exposes all of Guzzle’s configuration options directly via the
ClientHandler, including proxy settings, cookies, redirects, and SSL certificates.
Removed
- Deprecated
fetchAsyncMethod: ThefetchAsyncfunction has been fully removed, replaced by the newasync()helper function. This provides better async handling and aligns with the new architecture based on PHP Fibers. - Symfony
ResponseDependency: Completely removed the dependency on Symfony’sResponseclass in favor of Guzzle’s PSR-7 compliantResponseimplementation. This reduces the package size and simplifies the dependencies.
Fixed
- Laravel 10 Compatibility Enhancements: Improved compatibility with Laravel 10 and Symfony 6.x by resolving issues related to HTTP foundation conflicts. The package now supports a wider range of Symfony and Laravel versions without dependency clashes.
- Async Error Handling: Fixed issues with async request error handling, ensuring that promises are properly resolved or rejected with meaningful exception messages.
- Persistent Guzzle Client Instances: Fixed an issue where a new Guzzle client was instantiated for every request. The Guzzle client is now reused efficiently across both sync and async operations.
v1.2.0
Added
- Guzzle PSR-7 Response Support: Introduced the
guzzlehttp/psr7library for managing HTTP responses, providing more flexibility and aligning with PSR-7 standards. - Enhanced Error Handling: Improved error handling for both synchronous and asynchronous requests using Guzzle's
RequestException. - New README Documentation: Updated the README to reflect the changes in response handling and usage of the
guzzlehttp/psr7response.
Changed
- Refactor Response Class: The
Responseclass now extendsguzzlehttp/psr7\Responseinstead of Symfony'sResponse, reducing dependency overhead and improving compatibility with PSR-7. - HTTP Request Handling: Refactored the
Httpclass to ensure seamless request handling with the newguzzlehttp/psr7response model. - Removed Symfony Response Dependency: Dropped Symfony's
Responseclass in favor of the more lightweight and standardguzzlehttp/psr7.
Fixed
- Laravel 10 Compatibility: Addressed compatibility issues with Laravel 10 by ensuring the package can work with Symfony 6.x versions while allowing flexibility for future upgrades.
- Composer Dependency Conflicts: Resolved conflicts with Symfony’s HTTP Foundation, ensuring compatibility for projects that depend on specific versions of Symfony and other packages.
- Asynchronous Error Handling: Fixed issues related to handling exceptions in asynchronous requests, ensuring proper error handling and promise resolution.
v1.1.1
Changed
- Updated Composer Dependencies:
Thesymfony/http-foundationdependency has been updated to support versions^6.0 || ^7.0, ensuring compatibility with Laravel 10 and future versions. This change allows smooth integration with Laravel 9.x, 10.x, and future Laravel versions without version conflicts. - Enhanced Test Suite for Compatibility:
The GitHub Actions test matrix has been expanded to test against Laravel 9.x, 10.x, and 11.x, ensuring future compatibility with new Laravel releases.
Fixed
- Compatibility Issue with Laravel 10:
The package had an installation conflict when used with Laravel 10 due to outdatedsymfony/http-foundationversion constraints. This release resolves the issue, allowing users to install the package without dependency conflicts in Laravel 10 environments.
v1.1.0
Changed
HttpClass: The HTTP request handling has been abstracted away into a newHttpclass, improving the overall structure of the library and allowing for cleaner, centralized management of requests via Guzzle.- Guzzle Client Reuse: The Guzzle client is now instantiated as a singleton, meaning it is created once and reused across all HTTP requests. This change improves the performance of the library when making multiple requests.
- Deprecation of
fetchAsync: ThefetchAsyncmethod is now deprecated in favor offetch_async. A deprecation warning has been added to guide users to transition to the new method.
Fixed
- Guzzle Client Instantiation Issue: Resolved an issue where the Guzzle client was instantiated for every HTTP request, leading to performance inefficiencies. Now, the client is reused across requests, reducing overhead.