PHPackages                             chriskonnertz/deeply - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. chriskonnertz/deeply

ActiveLibrary[API Development](/categories/api)

chriskonnertz/deeply
====================

DeepLy is a PHP client for the DeepL.com translation API

v2.2.0(2y ago)229126.4k↓33.3%48[3 issues](https://github.com/chriskonnertz/DeepLy/issues)6MITPHPPHP &gt;=8.0CI failing

Since Aug 31Pushed 2y ago10 watchersCompare

[ Source](https://github.com/chriskonnertz/DeepLy)[ Packagist](https://packagist.org/packages/chriskonnertz/deeply)[ RSS](/packages/chriskonnertz-deeply/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (1)Versions (31)Used By (6)

[![alt text](https://camo.githubusercontent.com/9b867f0c47a2e8ffcdc0870b81b760272fe75ad800fb59a7c8dacec2ece0ec93/68747470733a2f2f692e696d6775722e636f6d2f6e575074414b672e706e67 "DeepLy Logo")](https://camo.githubusercontent.com/9b867f0c47a2e8ffcdc0870b81b760272fe75ad800fb59a7c8dacec2ece0ec93/68747470733a2f2f692e696d6775722e636f6d2f6e575074414b672e706e67)

DeepLy 2
========

[](#deeply-2)

[![Build Status](https://camo.githubusercontent.com/4993c529c0655d7cf4bf68700c93deb6bef3d95a7270612fac5c837f82c9a4d3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63687269736b6f6e6e6572747a2f446565704c792f7068702e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/chriskonnertz/DeepLy/actions)[![Version](https://camo.githubusercontent.com/b3bacac3c8f32b9add4f12f10eb66201b2bcd8b0249b3bca98dcf065ad392419/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63687269736b6f6e6e6572747a2f446565704c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chriskonnertz/deeply)[![GitHub license](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://raw.githubusercontent.com/chriskonnertz/deeply/master/LICENSE)[![Version](https://camo.githubusercontent.com/b3f993045a444fe0151217464f2218c90ed8afbc6dd6abe969f282917932a644/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63687269736b6f6e6e6572747a2f646565706c793f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chriskonnertz/deeply)

[DeepL](https://www.deepl.com/) is a next-generation translation service. DeepLy is a dependency-free PHP library that implements a client to interact with the [DeepL API](https://www.deepl.com/docs-api) using an API key. You can get an API key for free on their [website](https://www.deepl.com/). DeepLy automatically supports both the free and the pro API. For interactive demo scripts take a look at the [demos folder](demos).

Installation
------------

[](#installation)

This library requires PHP 8.0 or higher and the cURL extension. Install DeepLy trough [Composer](https://getcomposer.org/):

```
composer require chriskonnertz/deeply

```

Examples
--------

[](#examples)

```
$deepLy = new ChrisKonnertz\DeepLy\DeepLy('your-api-key');

$translatedText = $deepLy->translate('Hello world!', 'DE');

echo $translatedText; // Prints "Hallo Welt!"
```

> 💡 An interactive PHP demo script is included. It is located at [demos/demo\_translate.php](demos/demo_translate.php).

### Sophisticated Example

[](#sophisticated-example)

```
$deepLy = new ChrisKonnertz\DeepLy\DeepLy('your-api-key');

try {
    $translatedText = $deepLy->translate('Hello world!', DeepLy::LANG_EN, DeepLy::LANG_AUTO);

    echo $translatedText; // Prints "Hallo Welt!"
} catch (\Exception $exception) {
    echo $exception->getMessage();
}
```

Always wrap calls of the `translate` method in a try-catch-block, because they might throw an exception if the arguments are invalid or the API call fails. The exception will have an explanatory message and a specific error code.

Instead of using hardcoded strings as language arguments better use the language code constants of the `DeepLy` class. The class also offers methods such as `getLangCodes($withAuto = true)` and `supportsLangCode($langCode)`.

If you need to specify advanced settings, use the `setSettings()` method: `$deepLy->setSettings($glossaryId);`

Auto-Detect Language
--------------------

[](#auto-detect-language)

> ⚠️ ATTENTION: Using this method increases the usage statistics of your account!

DeepLy has a method that uses the DeepL API to detect the language of a text:

```
$languageCode = $deepLy->detectLanguage('Hello world!');
```

This will return 'EN'. The language of the text has to be one of the supported languages or the result will be incorrect. If you do not need the code of the language but its English name, you may call the `$deepLy->getLangName($langCode)` method.

The API, in general, can handle and completely translate texts that contain parts with different languages, if the language switch is not within a sentence. The `detectLanguage()` method will however only return the code of *one* language. It will throw an exception if it is unable to auto-detect the language. This will rarely happen, it is more likely that the API will return a "false positive": It will rather detect the wrong language than no language at all.

> 💡 An interactive PHP demo script is included. It is located at [demos/demo\_detect](demos/demo_detect.php).

Supported Languages
-------------------

[](#supported-languages)

DeepL(y) supports these languages:

CodeLanguageCodeLanguageauto*Auto detect*KOKoreanIDIndonesianTRTurkishITItalianZHChineseBGBulgarianLTLithuanianCSCzechLVLatvianDADanishNBNorwegianDEGermanNLDutchELGreekPLPolishENEnglishPTPortugueseESSpanishRORomanianETEstonianRURussianFIFinnishSKSlovakPTFrenchSLSlovenianHUHungarianSVSwedishJAJapanese> 💡 Note that only the source language can be auto-detected.

Glossaries
----------

[](#glossaries)

To get a list with information about all your glossaries, do:

```
$glossaries = $deepLy->getGlossaries();
print_r($glossaries); // Prints an array with Glossary objects
```

Output:

```
Array
(
    [0] => ChrisKonnertz\DeepLy\Models\Glossary Object
        (
            [glossaryId] => 56cab399-ac8e-4a57-aadc-fa95103f2de5
            [entryCount] => 2
            ...
        )
    [2] => ChrisKonnertz\DeepLy\Models\Glossary Object
        (
            [glossaryId] => d9eb53b5-3929-49a1-b5e1-df1eb8be93c9
            [entryCount] => 5
            ...
        )
)

```

To get information about a specific glossary, do:

```
$glossary = $deepLy->getGlossary('your-glossary-id');
print_r($glossary); // Prints a \stdClass
```

Output:

```
ChrisKonnertz\DeepLy\Models\Glossary Object
(
    [glossaryId] => d9eb53b5-3929-49a1-b5e1-df1eb8be93c9
    [name] => DeepLy Test
    [ready] => 1
    [from] => en
    [to] => de
    [creationTimeIso] => 2022-04-21T17:46:31.83913+00:00
    [creationDateTime] => DateTime Object
    [entryCount] => 2
)

```

To get the translation entries of a specific glossary, do:

```
$entries = $deepLy->getGlossaryEntries('your-glossary-id');
print_r($entries);  // Prints an array with string items
```

Output:

```
Array
(
    [Entry 1 DE] => Entry 1 EN
    [Entry 2 DE] => Entry 2 EN
)

```

To create a new glossary with translation entries, do:

```
$glossary = $deepLy->createGlossary('test', 'de', 'en', ['Example DE' => 'Example EN']);
```

To delete an existing glossary, do:

```
$deepLy->deleteGlossary('your-glossary-id');
```

> 💡 An interactive PHP demo script is included. It is located at [demos/demo\_glossaries.php](demos/demo_glossaries.php).

Documents
---------

[](#documents)

Translating documents consists of three steps. The first step is to upload a document:

```
$filename = __DIR__.'/test_document_original.pdf';
$result = $deepLy->uploadDocument($filename, 'DE');

var_dump($result);
```

Output:

```
ChrisKonnertz\DeepLy\Models\DocumentHandle Object
(
  [documentId] => D014F316B7A173079074BE76F530F846
  [documentKey] => 39FF8B10D20621096F23BF96CC103E12074727007C62963CF49AE8A9965D7695
)

```

> 💡 The maximum upload limit for any document is 10 MB and 1.000.000 characters.
>
> ⚡ Every file upload is at least billed with 50.000 characters!

The second step is to wait for the DeepL.com API to finish processing (translating) the document. You can check the state:

```
$result = $deepLy->getDocumentState($result->documentId, $result->documentKey);

var_dump($result);
```

Output:

```
ChrisKonnertz\DeepLy\Models\DocumentState Object
(
    [documentId] => D014F316B7A173079074BE76F530F846
    [status] => done
    [billedCharacters] => 50000
    [secondsRemaining] => null
)

```

In this case the document has been processed. This is indicated by "status" being "done" and "seconds\_remaining" being *null*.

> 💡 The document life cycle is: *queued* ➜ *translating* ➜ *done* (or *error*)
>
> There are constants that you can use to check these values: `DocumentState\STATUS_DONE` etc.

The third step is to download the document:

```
$deepLy->downloadDocument($documentId, $documentKey, 'test_document_translated.pdf');
```

If you do not want to store the file, do:

```
$contents = $deepLy->downloadDocument($documentId, $documentKey);
```

> ⚡ A document can only be downloaded once!

> 💡 An interactive PHP demo script is included. It is located at [demos/demo\_documents.php](demos/demo_documents.php).

Usage Statistic
---------------

[](#usage-statistic)

To get usage statistics, do:

```
$usage = $deepLy->usage(); // Returns an object of type "Usage"

echo $usage->characterCount.'/'.$usage->characterLimit
    . ' characters ('.round($usage->characterQuota * 100).'%)';
```

Depending on the user account type, some usage types will be null. Learn more:

Framework Integration
---------------------

[](#framework-integration)

DeepLy comes with support for Laravel 5.5+ and since it also supports [package auto-discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518)it will be auto-detected. However, you have to store your DeepL API key manually in the `.env` file, like this:

```
DEEPL_API_KEY = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

```

Afterwards you can access DeepLy like this: `$ping = \DeepLy::ping();`

HTTP Client
-----------

[](#http-client)

Per default DeepLy uses a minimalistic HTTP client based on cURL. If you want to use a different HTTP client, such as [Guzzle](https://github.com/guzzle/guzzle), create a class that implements the `HttpClient\HttpClientInterface`and makes use of the methods of the alternative HTTP client. Then use `$deepLy->setHttpClient($yourHttpClient)`to inject it.

> 💡 Note: If you experience issues with the integrated cURL client that could be solved by setting the `CURLOPT_SSL_VERIFYPEER` to `false`, first read this: [snippets.webaware.com.au/../](https://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/)
>
> If it does not help try: `$deepLy->getHttpClient()->setSslVerifyPeer(false)`

> 💡 You can set up a proxy with: `$deepLy->getHttpClient()->setProxy('ip:port', 'user:password')`

Tests
-----

[](#tests)

Export your API key:

```
export DEEPL_API_KEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

```

Run `composer install` from the DeepLy directory, then run the tests:

```
./vendor/phpunit/phpunit/phpunit

```

Differences to V1
-----------------

[](#differences-to-v1)

To upgrade from v1 to v2, make sure you specify the API key when instantiating the DeepLy object. Apart from the changes mentioned above your v1 code should still work with v2 as long as you did not write your own HTTP client or extended the DeepLy class with a custom class. To learn more about the changes, please take a look at the [changelog](CHANGELOG.md).

Disclaimer
----------

[](#disclaimer)

This is not an official package. It is 100% open source and non-commercial.

DeepL is a product of DeepL GmbH. More info: [deepl.com/publisher.html](https://www.deepl.com/publisher.html)

Notes
-----

[](#notes)

- Texts have to be UTF8-encoded.
- If you are looking for a real-world example application that uses DeepLy, you may take a look at [Translation Factory](https://github.com/chriskonnertz/translation-factory).
- The code of this library is formatted according to the code style defined by the
    [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) standard.
- Status of this repository: *Maintained*. Create an [issue](https://github.com/chriskonnertz/DeepLy/issues)and you will get a response, usually within 48 hours.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 99.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~76 days

Recently: every ~110 days

Total

29

Last Release

1094d ago

Major Versions

v0.9 → v1.0.02017-09-02

v1.6.1 → v2.0-beta2022-04-19

1.x-dev → v2.02022-04-23

PHP version history (2 changes)v0.1PHP &gt;=5.6.0

v2.0-betaPHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2548d359f2033681fd886f21a31406119a9ea3bd93dbec6f533f75f006f09228?d=identicon)[siconize](/maintainers/siconize)

---

Top Contributors

[![chriskonnertz](https://avatars.githubusercontent.com/u/4319323?v=4)](https://github.com/chriskonnertz "chriskonnertz (390 commits)")[![fbuchlak](https://avatars.githubusercontent.com/u/30214087?v=4)](https://github.com/fbuchlak "fbuchlak (1 commits)")

---

Tags

aiapiclientdeepli18nlanguagelaravellibrarymachine-translationneuralphptranslatetranslationtranslatorapiclientlanguagetranslatetranslationailibrarydeeplNeuraldeeply

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chriskonnertz-deeply/health.svg)

```
[![Health](https://phpackages.com/badges/chriskonnertz-deeply/health.svg)](https://phpackages.com/packages/chriskonnertz-deeply)
```

###  Alternatives

[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

46688.8k5](/packages/deepseek-php-deepseek-php-client)[gorkalaucirica/hipchat-v2-api-client

Hipchat v2 API client

81228.1k6](/packages/gorkalaucirica-hipchat-v2-api-client)[teknoo/sellsy-client

PHP library to connect your applications to your Sellsy account account using the Sellsy API and build your websites and your platforms on the Sellsy technology.

18213.1k](/packages/teknoo-sellsy-client)[qwen-php/qwen-php-client

robust and community-driven PHP SDK library for seamless integration with the qwen AI API, offering efficient access to advanced AI and data processing capabilities

203.3k1](/packages/qwen-php-qwen-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
