Download the PHP package cleargoal/laravel-deepl without Composer
On this page you can find all versions of the php package cleargoal/laravel-deepl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cleargoal/laravel-deepl
More information about cleargoal/laravel-deepl
Files in cleargoal/laravel-deepl
Package laravel-deepl
Short Description Laravel package for DeepL translation with multi-key management, quota tracking, and automatic key rotation
License MIT
Informations about the package laravel-deepl
Laravel DeepL Translation
A Laravel package for DeepL translation with advanced features:
- Multi-Key Management: Automatic rotation between multiple DeepL API keys from different accounts to increase total quota
- Quota Tracking: Per-key character usage tracking with automatic key selection
- Smart Caching: 5-minute cache TTL for API keys to reduce database queries
- Language Detection: Automatic source language detection
- Event-Driven: Laravel events for quota exhaustion notifications
- Graceful Degradation: Handles database unavailability during installation
- Filament Integration: Optional beautiful admin UI (auto-enabled when Filament is installed)
- Artisan Commands: Full CLI management without requiring UI
Requirements
- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- PostgreSQL, MySQL, or SQLite database
Installation
Install the package via Composer:
Publish Configuration
Publish the configuration file:
This creates config/deepl.php where you can customize package behavior.
Publish and Run Migration
Publish the migration:
Run the migration to create the platform_settings table:
Configuration
Add Your First API Key
Add your DeepL API key using the artisan command:
Parameters:
api-key: Your DeepL API keyrenewal-day: Day of month when quota renews (1-31)--label: Optional friendly name for the key
That's it! The key is now stored in the database and ready to use.
Optional: Customize Storage
If you want to use a different table or key name, add to your .env:
Usage
Basic Translation
Translate text from one language to another:
Translate to All Languages
Translate text to all supported languages at once:
Language Detection
Automatically detect the language of text:
Using Dependency Injection
You can also inject the service directly:
Managing API Keys
The package provides artisan commands for easy key management.
Important: To increase your total quota, each API key must be from a different DeepL account. Multiple keys from the same account share the same quota and won't increase your limit. Create separate DeepL Free accounts (different emails) to get 500,000 characters per account per month.
Add a New Key
List All Keys
This displays a table with all keys, showing:
- Index number
- Label
- Masked API key
- Status (Active/Inactive)
- Remaining quota
- Usage percentage
- Renewal day
Tip: Use --show-keys to display full API keys (be careful in shared environments).
Check Quota
Check all keys:
Check a specific key:
Remove a Key
The command will ask for confirmation. Use --force to skip confirmation.
Advanced: Programmatic API
If you're building an admin panel or need programmatic access, you can use the DeepLApiKeyManager service directly:
Filament Admin Panel Integration
If you're using Filament in your Laravel application, the package automatically provides a beautiful admin interface for managing DeepL API keys.
Installation
The Filament integration is automatically enabled when Filament is detected in your application. No additional configuration required!
If you don't have Filament yet:
Features
Once Filament is installed, you'll find a new "DeepL API Keys" page in your admin panel under the "Settings" navigation group. The interface provides:
Key Management:
- ➕ Add API Keys - Modal form with API key, label, and renewal day (use keys from different DeepL accounts to increase quota)
- 📋 List Keys - Table view with quota usage, status, and last check time
- ✏️ Edit Keys - Update label, renewal day, and active status
- 🗑️ Delete Keys - Remove keys with confirmation
Quota Monitoring:
- 🔄 Refresh Quotas - Bulk update all keys from DeepL API
- 📊 Usage Indicators - Color-coded quota usage (green/yellow/red)
- ⏰ Next Renewal - Shows when each key's quota will reset
- ⚠️ Stale Data Warnings - Alerts when local quota might be outdated
Security:
- 🔒 Masked API Keys - Keys are partially hidden by default
- 📋 Copy to Clipboard - Quick copy with visual confirmation
- 🔐 Reveal Full Keys - Optional full key display
Customization
Navigation Group: The page appears under "Settings" by default. To change this, publish the views:
Then edit resources/views/vendor/laravel-deepl/filament/pages/manage-deepl-keys.blade.php.
You can also extend the ManageDeepLKeys class in your own Filament panel:
Access Control: Use Filament's built-in policy system to restrict access:
Screenshots
The Filament interface provides:
- Table view with all your DeepL API keys
- Add Key button in the header
- Quota usage with color-coded indicators
- Quick actions (Check Quota, Edit, Delete) for each key
- Refresh All Quotas button to sync with DeepL API
No Filament? No Problem!
If you don't use Filament, the artisan commands provide full functionality via CLI. The Filament integration is completely optional and adds zero overhead if not installed.
Handling Quota Exhaustion
When all API keys are exhausted, the package fires a Laravel event that you can listen to:
Option 1: Event Listener
Create an event listener:
Register the listener in EventServiceProvider:
Option 2: Configuration Callback
Set a callback in config/deepl.php:
Supported Languages
- English (
en) - Ukrainian (
uk) - German (
de) - French (
fr) - Spanish (
es)
To add more languages, you can extend the $deeplCodes array in DeepLTranslationService.
How It Works
Automatic Key Rotation
The package automatically rotates between multiple API keys based on remaining quota:
- Keys are sorted by remaining quota (most available first)
- Each translation attempt tries keys in order
- If a key's quota is exceeded, the next key is tried automatically
- Character usage is tracked locally to minimize API calls
Note: Each API key must be from a different DeepL account. Keys from the same account share quota, so create separate free accounts (using different email addresses) to multiply your translation capacity. For example, 3 accounts = 1,500,000 characters/month (3 × 500,000).
Smart Caching
API keys are cached for 5 minutes to reduce database queries while still allowing dynamic updates.
Renewal Day Tracking
Each API key has a renewal_day (1-31) indicating when DeepL resets its monthly quota. The package uses this to:
- Calculate when exhausted keys will be available again
- Cache quota exhaustion notifications until the earliest renewal date
- Prevent spam notifications
Testing
The package includes comprehensive tests. To run them:
For test coverage:
For static analysis:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-deepl with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/cache Version ^10.0|^11.0|^12.0