Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use guzzlehttp/psr7 instead of symfony/http-foundation #6

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

Thavarshan
Copy link
Owner

@Thavarshan Thavarshan commented Sep 27, 2024

Purpose

This PR implements significant refactors to the Fetch PHP library, specifically addressing the transition from using Symfony's Response class to guzzlehttp/psr7 for managing HTTP responses. This change improves compatibility and reduces the dependency footprint of the library. Additionally, the README has been updated to reflect these changes, ensuring that documentation is consistent with the current implementation. This update resolves compatibility issues reported in Laravel 10 projects and future-proofs the package with more flexible response handling.

Related Issues: [#issue-link] (if applicable)

Approach

The primary focus of this change is refactoring the core Response class. The library now extends Guzzle's Psr7\Response, replacing the Symfony Response class. This adjustment simplifies the response handling process while maintaining the core functionality users expect from Fetch PHP. All available response methods (e.g., json(), text(), statusText()) have been adapted to ensure compatibility with this new architecture. Furthermore, the README was updated to document these changes clearly and concisely for developers using the library.

Key changes include:

  • Refactoring of the Response class to extend guzzlehttp/psr7 instead of Symfony's Response.
  • Updated the HTTP request and response handling methods to ensure compatibility with PSR-7 standards.
  • Improved error handling in both synchronous and asynchronous requests.
  • Updated README to reflect the changes and provide examples with the updated response handling methods.

Open Questions and Pre-Merge TODOs

  • Ensure backward compatibility is maintained for projects using older versions of Symfony.
  • Update any tests relying on Symfony's Response to ensure compatibility with the new response class.
  • Ensure that all provided examples in the documentation reflect the current implementation.

Learning

This update was based on research into transitioning from Symfony Response to PSR-7 standards using guzzlehttp/psr7. The goal was to simplify response handling and reduce dependencies, while maintaining the flexibility and feature set that Fetch PHP users are accustomed to. This required an in-depth understanding of both Symfony and Guzzle's HTTP components, as well as maintaining backward compatibility for existing users.

@Thavarshan Thavarshan added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 27, 2024
@Thavarshan Thavarshan self-assigned this Sep 27, 2024
@Thavarshan Thavarshan merged commit 59216aa into main Sep 27, 2024
14 checks passed
@Thavarshan Thavarshan deleted the refactor/use-guzzle-psr7 branch September 27, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant