DEV Community

Jitendra
Jitendra

Posted on • Edited on

adhocore/cron-expr- Ultralight and super fast PHP Cron parser

https://github.com/adhocore/php-cron-expr

This could possibly be the fastest crontab expression parser in PHP7 currently. Real benchmarks show that it is somewhere between 6-9x faster than existing solution.

Neat simple API

Just set a single cron entry for your PHP based scheduler once and for all like so:

* * * * * php /path/to/scheduler.php
Enter fullscreen mode Exit fullscreen mode

Then all you need to do is invoke your due jobs in scheduler.php, this is where cron-expr comes in play: it tells you if specific job/task is due at the moment with simple api. See a quick simple example below:

$job1Schedule = '*/5 * * * *';
$isJob1Due    = Ahc\Cron\Expression::isDue($job1Schedule);
Enter fullscreen mode Exit fullscreen mode

// run job 1 if due and so on for job 2 etc... !

Also supports some humanly tags for representing schedule intervals like @hourly, @daily, @10minutes.

[scrutinizer rating 10/10, test coverage 100%, version 0.0.4, dead simple usage, single api]

Top comments (0)