lorisleiva/cron-translator
Make CRON expressions human-readable in PHP/Laravel. Translate schedules like “*/2 * * * *” into natural language (“Every 2 minutes”), with optional locale and 24-hour time formatting. Supports many languages (en, fr, de, es, etc.).
App::getLocale()), enabling zero-config globalization for cron descriptions.AppServiceProvider for global access.CronTranslator::translate()).Artisan for CLI-based cron validation (e.g., php artisan cron:translate "0 * * * *").HandleJobsMiddleware or Schedule facade hooks).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| PHP Version Support | Requires PHP 8.2+ (Laravel 9+). | Blocker: Ensure project uses PHP 8.2+. If not, evaluate alternatives or upgrade. |
| Cron Syntax Limits | Supports standard cron but not all extensions (e.g., L, W, ?). |
Workaround: Pre-process unsupported expressions or document limitations. |
| Performance | Translation is O(1) for simple cron; complex expressions may add <1ms. | Benchmark: Test with worst-case cron (e.g., 1,2,3,4,5 * * * *) in load tests. |
| Localization Quality | Community-driven translations may have inconsistencies. | Fallback: Default to en or implement custom validation for critical locales. |
| Testing Coverage | No Laravel-specific tests; relies on unit tests for core logic. | Integration Tests: Add Laravel-specific test cases (e.g., facade binding). |
| Dependency Updates | No external dependencies, but PHP 8.5+ tests suggest future-proofing. | Monitor: Track PHP deprecations and update CI accordingly. |
@yearly, L)?Cache::remember()) for frequent cron expressions.CronTranslator as a singleton in AppServiceProvider.Cron::translate()) for consistency.Artisan for CLI debugging (e.g., cron:translate).@cron('* * * * *') for UI rendering.| Phase | Action | Tools/Dependencies |
|---|---|---|
| Assessment | Audit existing cron usage (e.g., schedule:run, TaskScheduler). |
grep, php artisan schedule:list |
| Proof of Concept | Replace hardcoded cron descriptions with CronTranslator in one feature (e.g., admin UI). |
Laravel Mix, Blade, Tailwind CSS (if UI) |
| Core Integration | Bind CronTranslator as a service and extend job logging or API responses. |
Laravel Service Container, Log Viewer |
| Localization | Configure app locale and test translations in all supported languages. | Laravel Localization, App::getLocale() |
| CLI/Dev Tools | Add Artisan command for debugging cron expressions in development. |
Laravel Artisan, Tinker |
| Documentation | Update API docs (OpenAPI) and internal wikis with translated cron examples. | Swagger UI, Postman, Markdown |
| Monitoring | Log translation performance metrics (e.g., execution time) for critical paths. | Laravel Debugbar, Prometheus |
* * * * *, 0 0 * * 1).@yearly, L may need custom parsing).0 0 * * * vs. @daily).en (English).App::getLocale() or pass manually (e.g., CronTranslator::translate('* * * * *', request()->locale)).CronTranslator as a service.GET /schedules/{id}).Artisan command for CLI debugging.How can I help you explore Laravel packages today?