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

FEATURE REQUEST: Add support for changing httpClient #19

Closed
Radon8472 opened this issue Feb 28, 2023 · 3 comments
Closed

FEATURE REQUEST: Add support for changing httpClient #19

Radon8472 opened this issue Feb 28, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Radon8472
Copy link

Radon8472 commented Feb 28, 2023

Currently you are using a static internal http client based on curl. It would be good if there would be an option to set an alternative http client (e.g. guzzlephp, php streams or any psr18 compatible client).

This would be usefull e.g. when you can`t use curl, or when you are using any framework with its own httpclient.

I would suggest to add a new option to the options array e.g.

  $translator = new \DeepL\Translator($authKey);
  $translator->translateText($text, $source, $target, [
      'httpClient' => new Psr18Client()
  ]);

The option httpClient should accept any client matching to an from predefined defined "HttpClientInterface" and you change your code to only use HttpClientInterface to be compatible with all comming implementations on this interface.

Benefit would be, you only need to implement the basic logic of passing new clients based on this interface, createing different clients could be done by the community.

examples how this could be done can be found in other projects using changeable http clients like here

EDIT:
This feature would automatically resolve #14 because you could ad or change an alternative curl client with custom config.

@daniel-jones-deepl
Copy link
Member

Hi @Radon8472, sorry that we didn't react to this issue earlier. @JanEbbing has been working on this feature, you can see the work in this comment.

@daniel-jones-deepl daniel-jones-deepl added the enhancement New feature or request label Jun 20, 2023
@JanEbbing
Copy link
Member

This is implemented now in the new v1.5.0, please update to use this feature (and feel free to provide any feedback).

@Radon8472
Copy link
Author

Radon8472 commented Jun 30, 2023

Hi @Radon8472, sorry that we didn't react to this issue earlier. @JanEbbing has been working on this feature, you can see the work in this comment.

@JanEbbing , @daniel-jones-deepl

I tested this feature in v1.5, but unfortunally it still has some bugs.
I created a new issue #29 for this, because it seems to be another context

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

No branches or pull requests

3 participants