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

PSR-17 and PSR-18 compability #5

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Basster
Copy link

@Basster Basster commented May 17, 2024

As we are going to use this library in our Symfony full-stack project, but we don't want to require an additional http-client, I've abstracted everything tightly coupled to guzzle out and replaced it with PSR-18 ClientInterfaces and PSR-17 RequestFactoryInterfaces.

This also adds a BC Break, since the Client now also implements the Psr\Http\Message\RequestFactoryInterface, so Psr\Http\Message\RequestInterface compatible requests can be created via the Client itself.

The RequestFactoryInterface to be used can be passed via the ClientOptions httpRequestFactory key and defaults to an anonymous implementation, returning a \GuzzleHttp\Psr7\Request, if guzzle is installed.

If guzzle is not installed and you forget to pass httpClient and httpRequestFactory to the ClientOptions, it will throw dedicated HttpClientExceptions.

I moved guzzlehttp/guzzle to require-dev, so it can be used for testing, but suggest it to be installed as a default http-client solution. Projects that installed an older version of this library may not break, since they already have guzzlehttp/guzzle installed as a dependency from the old version, but they must require it explicitly from now on.

@Basster Basster marked this pull request as ready for review May 17, 2024 07:07
@Basster Basster marked this pull request as draft May 17, 2024 08:25
@Basster
Copy link
Author

Basster commented May 17, 2024

I still see catching GuzzleExceptions. They will get tackled as well.

@Basster
Copy link
Author

Basster commented May 17, 2024

Multipart upload is another thing to be solved. As we are currently only reading from Canto, we don't have any real-world scenario to test on. Maybe one of the maintainers can help.

Left a //todo so far...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant