Skip to content

Examples

Greg Bowler edited this page Jun 22, 2026 · 3 revisions

The example/ directory is the quickest way to see the library working without building a full project first.

Run an example from the repository root:

php example/01-run-due-jobs.php

Each script embeds its own crontab string so the schedule and the code stay together.

01-run-due-jobs.php

This example shows the smallest useful flow:

  • create a Queue
  • parse a crontab string into it
  • run only the jobs due at a chosen time

It uses ScriptOutputMode::INHERIT so the command output is printed directly.

02-next-job.php

This example focuses on scheduling rather than execution.

It demonstrates:

  • running the jobs due now
  • asking the queue for the next run date
  • asking the queue for the next command due

This is a good page to read after Running the runner if you want the underlying API shape.

03-nickname-expressions.php

This example shows that nickname schedules such as @hourly and @daily are accepted as the first token on a line.

It is a small, concrete demonstration of the nickname support described in Crontab syntax.

04-custom-expression-factory.php

This example injects a custom ExpressionFactory that understands an extra @start token.

Read this alongside Custom expression factories if you want to extend the scheduler for your own project.

Clone this wiki locally