Skip to content

Deprecated HttpClient service, added ClientInterface #426

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

Closed
wants to merge 4 commits into from

Conversation

zerkms
Copy link

@zerkms zerkms commented Apr 19, 2023

Fixes #425

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? yes
Related tickets fixes #425
Documentation if this is a new feature, link to pull request in https://github.com/php-http/documentation that adds relevant documentation
License MIT

What's in this PR?

It deprecates exposing the deprecated Http\Client\HttpClient and adds default service Psr\Http\Client\ClientInterface.

Why?

Example Usage

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)

To Do

  • If the PR is not complete but you want to discuss the approach, list what remains to be done here

Copy link
Collaborator

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot!

@ostrolucky
Copy link
Collaborator

ostrolucky commented Apr 20, 2023

As you can see this doesn't work with old symfony versions. Time to drop them, or would you rather remove "package" from here?

@zerkms
Copy link
Author

zerkms commented Apr 20, 2023

or would you rather remove "package" from here?

this + add it as a comment in the xml

4.4 is still not EOL

@ostrolucky
Copy link
Collaborator

it's in security maintenance, which I consider EOL, similarly like people consider PHP 5.3 EOL while RHEL is still patching it. Most bundles dropped support of Symfony 4.4. Anyways I don't want to talk about it too much here, go either way here.

@dbu
Copy link
Collaborator

dbu commented Apr 20, 2023

i solved it like this in FOSHttpCacheBundle: https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/ef1bab770fbb2fc3f0f6a3e9c66dceb1cde58822/src/DependencyInjection/FOSHttpCacheExtension.php#L286 with https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/2.x/src/Resources/config/user_context_legacy_sf6.xml and https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/2.x/src/Resources/config/user_context_legacy.xml

the idea is to extract the deprecated alias into its own service configuration file and have the extension include the variant that works for the symfony version that is used. (i would invert the naming to what we did in the bundle, something like httplug_alias.xml for the new syntax and httplug_alias_legacy.xml for old symfony versions)

@@ -47,7 +47,10 @@
<service id="httplug.client.default" class="Http\Client\HttpClient">
<factory class="Http\Discovery\HttpClientDiscovery" method="find" />
</service>
<service id="Http\Client\HttpClient" alias="httplug.client" public="false" />
<service id="Http\Client\HttpClient" alias="httplug.client" public="false">
<deprecated package="php-http/httplug-bundle" version="1.28" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<deprecated package="php-http/httplug-bundle" version="1.28" />
<deprecated package="php-http/httplug-bundle" version="1.28">The "%service_id%" service is deprecated in favor of using PSR-7 Psr\Http\Client\ClientInterface directly</deprecated>

@dbu
Copy link
Collaborator

dbu commented May 12, 2023

thanks a lot @zerkms
i will wrap this up in #427

@dbu dbu closed this May 12, 2023
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.

Switch from Http\Client\HttpClient to Psr\Http\Client\ClientInterface
3 participants