Baby-Markt/deepl-php-lib

Fatal error: Uncaught Error: Class "DeepL" not found in

Flaschenzug opened this issue · 2 comments

I am running into the following error:
Fatal error: Uncaught Error: Class "DeepL" not found in

I use the following code:

require_once("../deepl-api/vendor/autoload.php"); // the path is correct, I tested that first

$deepl   = new DeepL('KEY',2,'api.deepl.com'); // KEY IS REPLACED WITH THE RIGHT KEY
return $deepl->translate('Hello World, 'en, 'fr');

Any ideas? Looks like other people does not have this problem?
Thanks a lot!

u-nik commented

Maybe you forgot the namespace? Either you have to use an use statement like use \BabyMarkt\DeepL at the beginning of your file or you must use the full qualified class name like new \BabyMarkt\DeepL\DeepL(...).

<?php

include "vendor/autoload.php";

$deepl = new \BabyMarkt\DeepL\DeepL('KEY',2,'api.deepl.com');

ah, amazing. Thank you :-)
Just had to use api-free.deepl.com, but now I get the translations.

$deepl = new \BabyMarkt\DeepL\DeepL($authKey,2,'api-free.deepl.com');

Thanks a lot :-)