Skip to content

Examples

Greg Bowler edited this page May 17, 2026 · 2 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.

05-explain-crontabs.php

This example shows how to feed a few different crontab lines through CronExplainer.

It demonstrates:

  • uppercase nickname expressions
  • second-based schedules
  • weekday lists
  • nth weekday expressions with a month restriction

Read this alongside Crontab syntax or Running the runner if you want a quick way to check that a schedule says what you expect.

Clone this wiki locally