Weave 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 Expression

Cron Expression Laravel Package

kfosoft/cron-expression

A PHP package for parsing and working with cron expressions, helping validate schedules and determine when cron jobs should run. Suitable for Laravel and standalone PHP projects that need simple, reliable cron expression handling.

Deep Wiki
Context7

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due

Frequently asked questions about Cron Expression
How do I install kfosoft/cron-expression in a Laravel project?
Install it with Composer using composer require kfosoft/cron-expression. In Laravel, you can use the package directly from application code such as console commands, jobs, or services. Check the package README for any Laravel-specific configuration or facade details.
Can kfosoft/cron-expression calculate the next run date for a cron schedule?
Yes, the package is designed to calculate the next or previous run date for a cron expression. You provide a cron expression and a reference date and time, and it determines the next matching run time. This is useful for previewing schedules and confirming that a job will run when expected.
How do I determine if a cron expression is due right now?
The package can determine if a CRON expression is due by comparing the expression against the current or supplied date and time. You parse the expression and check whether the schedule matches the moment you are evaluating. This helps avoid running jobs outside their intended schedule. Exact method names should be confirmed in the package README.
Does kfosoft/cron-expression support Laravel's scheduler?
It is a PHP cron expression library suitable for Laravel projects, but it is not the same as Laravel's built-in scheduler. Laravel's scheduler uses cron expressions to decide when to run scheduled tasks, and this package can help you parse, validate, or calculate those expressions in your own code. For normal scheduled tasks, you can continue using Laravel's scheduler directly.
Which Laravel versions are supported by kfosoft/cron-expression?
The provided context does not specify Laravel version constraints. Because the package is a standalone PHP library that can be used in Laravel, compatibility generally depends on your PHP version and Composer requirements rather than a specific Laravel release. Check the package composer.json and README for exact PHP and Laravel support details.
Is kfosoft/cron-expression suitable for standalone PHP projects without Laravel?
Yes, the package is described as suitable for both Laravel and standalone PHP projects. It focuses on parsing cron expressions and calculating run dates, so it does not require Laravel to function. You can install it via Composer in any PHP project that needs cron schedule handling.
How can I validate a cron expression before saving it?
You can use the package to parse a cron expression and confirm it is valid before storing it. Invalid expressions should fail parsing or be rejected by the library's validation logic. This is useful in admin forms or configuration screens where users enter custom schedules. Confirm the exact validation API in the package documentation.
Can I calculate the previous run date as well as the next run date?
Yes, the package overview states it can calculate the next or previous run date. This is helpful for auditing when a job should have last run based on its cron expression. You supply the expression and a reference time, and the package finds the matching previous occurrence.
How do I test code that uses kfosoft/cron-expression?
Because the package calculates run dates from cron expressions and reference times, you can test it by passing fixed date and time values instead of relying on the current time. Use your normal PHPUnit or Laravel testing setup and assert the expected next or previous run dates. Avoid time-dependent assertions by freezing or mocking the clock where possible.
What are alternatives to kfosoft/cron-expression for cron parsing in PHP?
Other PHP cron expression libraries exist, such as dragonmantank/cron-expression, and Laravel's scheduler includes cron expression handling internally. The best choice depends on your need for standalone use, Laravel integration, and API preferences. kfosoft/cron-expression is aimed at simple, reliable parsing and next or previous run date calculation.
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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin