Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Cron Translator

Cron Translator Laravel Package

lorisleiva/cron-translator

Translate CRON expressions into clear, human-readable schedules. Supports common patterns (ranges, steps, lists) and multiple locales, with optional 24-hour time formatting. Ideal for showing CRON schedules in UIs and logs.

View on GitHub
Deep Wiki
Context7

⏰️ Makes CRON expressions human-readable

Frequently asked questions about Cron Translator
How do I install and use this package in Laravel?
Install via Composer with `composer require lorisleiva/cron-translator`. Use `CronTranslator::translate('* * * * *')` anywhere in your code. For Laravel services, bind it in a provider or inject directly. Works in Blade, APIs, and CLI.
Does this support Laravel Task Scheduling cron syntax?
Yes, it handles standard 5-field cron expressions (e.g., `* * * * *`). For extended syntax (e.g., `L`, `W`), validate input first or extend the package via PR. Pair with `spatie/cron-expression` for robust validation.
Can I use this in Blade templates for admin dashboards?
Absolutely. Embed it in Blade with `@php echo CronTranslator::translate($cronExpr) @endphp`. For performance, cache translations if used frequently in high-traffic dashboards.
What locales are supported, and how do I add more?
18 locales are included (e.g., `en`, `fr`, `zh-TW`). Add missing locales by submitting a PR to the GitHub repo. For urgent needs, pre-process translations in your app layer.
Will this work in Laravel APIs for JSON responses?
Yes, it’s API-friendly. Use it to return human-readable cron descriptions in webhook docs or task schedules. Cache translations for identical cron expressions to avoid redundant parsing.
Does it support 24-hour time formatting?
Yes, pass `true` as the third argument to enforce 24-hour format: `CronTranslator::translate('30 18 * * *', 'fr', true)`. Defaults to 12-hour with AM/PM.
What’s the performance impact of translating cron expressions?
Translation is O(1) for simple cron, with negligible overhead. For complex expressions (e.g., `1,2 0 */2 1,2 *`), benchmark in production if used in hot paths like API responses.
How do I handle invalid or unsupported cron syntax?
Validate input cron expressions before translation (e.g., using `spatie/cron-expression`). Define a fallback message like `Invalid cron format` or log errors for debugging.
Can I integrate this with Laravel’s service container?
Yes, wrap it in a Laravel service provider for dependency injection (e.g., `app('cron-translator')`). This improves testability and maintainability in larger applications.
What are the PHP version requirements?
Requires PHP 8.2+. If using older PHP, fork the package or polyfill (though not recommended). The package leverages PHP 8.2+ features like strong typing.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony