Skip to content

Call to undefined function DeepL\curl_version() in deeplcom\deepl-php\src\Translator.php:738 #29

Open

Description

@Radon8472

I tried to change the http-client like shown in the README section - Custom HTTP client.

What results in Error:

 Call to undefined function DeepL\curl_version() in deeplcom\deepl-php\src\Translator.php:738

Here is my code to find this error:

$client = new \GuzzleHttp\Client([
    'handler' => new \GuzzleHttp\Handler\StreamHandler()
]);

$translator = new \DeepL\Translator($authKey);
$translator->translateText($text, $source, $target, [
    TranslatorOptions::HTTP_CLIENT => $client
]);

So it seems that even when you chance the HttpClient, the Translator Class still tries to use method/functions related to Curl HttpClient for building the user-agend string.

Suggestion to fix:

  1. check which Guzzle handler is used
  2. Only is a handler is used, that extends CurlHandler, set $libraryInfoStr to " curl/$curlVer"
  3. for other Handler, either don`t add this info, or find a way to get similar infos from the other Handler classes

Activity

  1. JanEbbing commented on Jun 30, 2023

    @JanEbbing
    Contributor

    Thanks for reporting this. I didn't want the spaghetti code in the constructUserAgentString, but it seems it needs to know about a bunch of things to properly report. This will be fixed in the next patch.

  2. JanEbbing commented on Jul 10, 2023

    @JanEbbing
    Contributor

    Hi @Radon8472 , I tested my changes that remove this just now by building PHP from source without the cURL extension, but deepl-php has curl-ext as part of its requirements at the moment, so it won't install. Do you get this error with the cURL extension installed? You can check this for example with php -i | grep curl. The output is empty when you don't have the extension installed.

  3. Radon8472 commented on Jul 12, 2023

    @Radon8472
    Author

    Hi @Radon8472 , I tested my changes that remove this just now by building PHP from source without the cURL extension, but deepl-php has curl-ext as part of its requirements at the moment, so it won't install. Do you get this error with the cURL extension installed? You can check this for example with php -i | grep curl. The output is empty when you don't have the extension installed.

    You are right. in My local dev system based on xampp, I dont have this error when I activate curl.
    But when I push the files to my life system (where I don`t have curl) I get the error.

    You are using guzzle, and guzzle can run fine without curl using the native php streams or socket based Handlers, so I would recommend to move the curl dependency from the require section to suggested.

    Otherwise you would stop everybody without curl extension from using deepl, and I see no reason for this, when you are using guzzle, what is made to be useable with native php too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions