PHPackages                             octfx/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. octfx/deeply

ActiveLibrary[API Development](/categories/api)

octfx/deeply
============

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

3.1.4(4y ago)34.2k1MITPHPPHP &gt;=7.2

Since Aug 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/octfx/DeepLy)[ Packagist](https://packagist.org/packages/octfx/deeply)[ RSS](/packages/octfx-deeply/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (31)Used By (0)

DeepLy
======

[](#deeply)

[DeepL.com](https://www.deepl.com/) is a great, new translation service. It provides better translations compared to other popular translation engines. DeepLy is a PHP package that implements a client to interact with DeepL via their API, with optional Laravel integration.

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

[](#installation)

Through [Composer](https://getcomposer.org/):

```
composer require octfx/deeply

```

From then on you may run `composer update` to get the latest version of this library.

It is possible to use this library without using Composer but then it is necessary to register an [autoloader function](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md#example-implementation).

> This library requires PHP 7.2 or higher, the mbstring, and json extension.

Deepl offers a free API Key with a 500k characters translation limit per month. Vist [DeepL-com](https://deepl.com/) to request an API key.

Usage Example
-------------

[](#usage-example)

```
$deepLy = new Octfx\DeepLy\DeepLy('Your-API-Key');

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

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

### Sophisticated Example

[](#sophisticated-example)

```
use Octfx\DeepLy\DeepLy;

$apiKey = 'Your-API-Key';
$deepLy = new DeepLy($apiKey);

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

    echo $translatedText; // Prints "Hallo Welt!"
} catch (AuthenticationException $e) {
    // API Key invalid
    // Code 403
} catch (QuotaException $e) {
    // Quota exceeded
    // Code 456
} catch (RateLimitedException $e) {
    // Ratelimited
    // Code 429
} catch (TextLengthException $e) {
     // Textlength > 30000 chars
} catch (CallException $e) {
    // Other errors
    // See: https://www.deepl.com/docs-api.html?part=accessing
}
```

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. 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 `supportsSourceLangCode($langCode)` and `supportsTargetLangCode($langCode)`.

Translation formality
---------------------

[](#translation-formality)

The DeepL API allows to specify the formality of the translated text.
This feature currently works for all target languages except "ES" (Spanish), "JA" (Japanese) and "ZH" (Chinese).
Possible options are:

- "default" (default)
- "more" - for a more formal language
- "less" - for a more informal language

```
$deepLy->formality('less');

// or
$translatedText = $deepLy->translate('Hello world!', DeepLy::LANG_EN, DeepLy::LANG_AUTO, 'more');
```

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

[](#auto-detect-language)

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 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.

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

[](#supported-languages)

All supported languages by DeepL can be requested by calling

```
$deepLy->getSupportedLanguages('source'); // all supported source languages
$deepLy->getSupportedLanguages('target'); // all supported target languages
```

DeepL(y) supports these source languages:

CodeLanguageauto*Auto detect*DEGermanENEnglishFRFrenchITItalianJAJapaneseESSpanishNLDutchPLPolishPTPortugueseRURussianZHChineseDeepL(y) supports these target languages:

CodeLanguageDEGermanEN-GBEnglish (British)EN-USEnglish (American)ENDEPRECATEDFRFrenchITItalianJAJapaneseESSpanishNLDutchPLPolishPTDEPRECATEDPT-PTPortuguese (all)PT-BRPortuguese (Brazilian)RURussianZHChinese> Note that auto detection only is possible for the source language.

Text Length Limit
-----------------

[](#text-length-limit)

According to the DeepL.com website, the length of the text that has to be translated is limited to 30000 characters. Per default DeepLy will throw an exception if the length limit is exceeded. You may call `$deepLy->setValidateTextLength(false)` to disable this validation.

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

[](#http-client)

Per default DeepLy uses a HTTP client based on Guzzle. If you want to use a different HTTP client, 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.

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

[](#framework-integration)

DeepLy comes with support for Laravel 5.x - 7.x 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 in Laravel 5.5 - 7.x

In Laravel 5.0-5.4 you manually have to register the service provider `Octfx\DeepLy\Integrations\Laravel\DeepLyServiceProvider` in the "providers" array and the facade `Octfx\DeepLy\Integrations\Laravel\DeepLyFacade` as an alias in the "aliases" array in your `config/app.php` config file.

DeepLy uses `config('services.deepl.auth_key')` to retrieve the API key, so you have to set it in the `services.php` settings.

```
return [
    'deepl' => [
        'auth_key' => env('DEEPL_AUTH_KEY'),
    ],
];
```

Request Limit
-------------

[](#request-limit)

There is a request limit. The threshold of this limit is specified in the quota documentation delivered to you by DeepL.

Internals
---------

[](#internals)

The "core" of this library consists of these classes:

- `DeepLy` - main class
- `HttpClient\GuzzleHttpClient` - HTTP client class
- `Protocol\JsonProtocol` - JSON is the protocol used by the DeepL API
- `ResponseBag\AbstractBag` - base wrapper class for the responses of the DeepL API
- `ResponseBag\UsageBag` - concrete class for API responses to usage statistics requests
- `ResponseBag\TranslationBag` - concrete class for API responses to "translate" requests

There are also some exception classes, interfaces, an alternative HTTP client implementation that uses Guzzle and classes for the Laravel integration.

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)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 89.3% 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 ~55 days

Recently: every ~117 days

Total

29

Last Release

1643d ago

Major Versions

v0.9 → v1.0.02017-09-02

v1.6.0 → 3.0.02019-10-21

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

3.0.0PHP &gt;=7.1

3.1.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6594492?v=4)[H. C. Kruse](/maintainers/Octfx)[@octfx](https://github.com/octfx)

---

Top Contributors

[![chriskonnertz](https://avatars.githubusercontent.com/u/4319323?v=4)](https://github.com/chriskonnertz "chriskonnertz (310 commits)")[![octfx](https://avatars.githubusercontent.com/u/6594492?v=4)](https://github.com/octfx "octfx (37 commits)")

---

Tags

deeplphp-librarytranslation-apiapiclientlanguagetranslatetranslationenglishdeeplfrenchdeeplygerman

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[chriskonnertz/deeply

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

230116.2k8](/packages/chriskonnertz-deeply)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[eko/googletranslatebundle

A Symfony bundle to deals with Google Translate API

4337.1k](/packages/eko-googletranslatebundle)

PHPackages © 2026

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