Skip to content

Switch from Http\Client\HttpClient to Psr\Http\Client\ClientInterface #425

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
zerkms opened this issue Apr 19, 2023 · 4 comments · Fixed by #427
Closed

Switch from Http\Client\HttpClient to Psr\Http\Client\ClientInterface #425

zerkms opened this issue Apr 19, 2023 · 4 comments · Fixed by #427

Comments

@zerkms
Copy link

zerkms commented Apr 19, 2023

Description

Starting httplug v2.4.0 the Http\Client\HttpClient interface is deprecated in favour of Psr\Http\Client\ClientInterface

Changelog: https://github.com/php-http/httplug/blob/625ad742c360c8ac580fcc647a1541d29e257f67/CHANGELOG.md

Example

Additional context

@dbu
Copy link
Collaborator

dbu commented Apr 19, 2023

we want to keep using the adapters to still provide the HttpAsyncClient. the Httplug HttpClient extends the PSR ClientInterface, people should depend on that rather than the deprecated HttpClient interface.

if you find places where we can update the documentation or code to talk about the PSR ClientInterface, glad if you can point them out or even do a pull request to cleanup things.

@zerkms
Copy link
Author

zerkms commented Apr 19, 2023

In that case - is it possible then to create a default alias for the Psr\Http\Client\ClientInterface

$ ./bin/console debug:container|grep httplug.client
  Http\Client\HttpClient                                                               alias for "httplug.client.default"                                                                 
  Http\Client\HttpClient $default                                                         alias for "httplug.client.default"                                                                 
  Psr\Http\Client\ClientInterface $default                                                alias for "httplug.client.default"                                                                 
  httplug.client                                                                       alias for "httplug.client.default"                                                                 
  httplug.client.default                                                               alias for "httplug.client.default"                                                                 
  httplug.client.default                                                                  Http\Client\Common\PluginClient                                                                 
  httplug.client.default.client                                                           Http\Client\HttpClient                                                                          
  httplug.client.default.plugin.base_uri                                                  Http\Client\Common\Plugin\BaseUriPlugin                                                         
  httplug.client.default.plugin.base_uri.base_uri                                         Psr\Http\Message\UriInterface              

That's what we have now: it's possible to type hint Http\Client\HttpClient but Psr\Http\Client\ClientInterface is not hinteable unless the name is changed to $default everywhere in the codebase.

@dbu
Copy link
Collaborator

dbu commented Apr 19, 2023

oh indeed, we should do that. it would be another line right after https://github.com/php-http/HttplugBundle/blob/1.x/src/Resources/config/services.xml#L50 (and we could mark the alias for HttpClient as deprecated.)

do you want to create a pull request for that?

@zerkms
Copy link
Author

zerkms commented Apr 19, 2023

I totally will do tomorrow then :-)

zerkms pushed a commit to zerkms/php-http-HttplugBundle that referenced this issue Apr 19, 2023
zerkms pushed a commit to zerkms/php-http-HttplugBundle that referenced this issue Apr 19, 2023
dbu pushed a commit that referenced this issue May 12, 2023
@dbu dbu closed this as completed in #427 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
2 participants