Download the PHP package ipl/scheduler without Composer
On this page you can find all versions of the php package ipl/scheduler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ipl/scheduler
More information about ipl/scheduler
Files in ipl/scheduler
Informations about the package scheduler
Icinga PHP Library - Tasks Scheduler
ipl-scheduler provides an event-loop-driven task scheduler for PHP. It runs
tasks at regular intervals or once at a specific time, using an event-driven
and promise-based model built on top of ReactPHP.
Tasks are plain PHP classes. Frequency is configured independently via cron expressions, one-off datetimes, or iCalendar recurrence rules. The scheduler emits lifecycle events so you can observe scheduling, execution, completion, failures, and expiration without coupling your tasks to the scheduler itself.
Installation
The recommended way to install this library is via Composer:
ipl/scheduler requires PHP 8.2 or later.
For production use, install the ext-ev
PHP extension to improve event loop efficiency.
Key Abstractions
| Class | Description |
|---|---|
Scheduler |
Manages tasks in the ReactPHP event loop |
Cron |
Repeating frequency driven by a cron expression |
RRule |
Repeating frequency driven by an iCalendar RRULE |
OneOff |
Single-run frequency at an exact point in time |
Usage
Implementing a Task
Implement the Task interface. Use the TaskProperties trait to satisfy the
getName(), getUuid(), and getDescription() requirements without
boilerplate.
Return resolve() or reject() when the result is already available synchronously.
For background work such as async I/O, subprocess calls, or non-blocking HTTP requests,
use a Deferred and settle it once the operation finishes:
Note: Always call either
resolve()orreject()on every code path. ADeferredwhose promise is never settled will silently preventON_TASK_DONEandON_TASK_FAILEDfrom firing.
Scheduling with a Cron Expression
Use Cron to run a task on a repeating schedule defined by a standard
five-field cron expression:
Scheduling a One-Off Run
Use OneOff to run a task exactly once at a specific datetime:
Scheduling with an iCalendar Recurrence Rule
Use RRule for complex recurrence patterns. Pass a timezone string to align
recurrences with a specific offset:
You can also construct an RRule directly from an RRULE string:
Listening to Lifecycle Events
The scheduler emits events at each stage of a task's lifecycle. Register
listeners using on():
Available Events
| Constant | Triggered when |
|---|---|
Scheduler::ON_TASK_SCHEDULED |
An operation is queued for future execution |
Scheduler::ON_TASK_RUN |
An operation starts running |
Scheduler::ON_TASK_DONE |
An operation completes successfully |
Scheduler::ON_TASK_FAILED |
An operation throws or rejects |
Scheduler::ON_TASK_EXPIRED |
A task has passed its configured end time |
Scheduler::ON_TASK_CANCEL |
A task is removed while an operation is pending |
Removing a Task
Call remove() to cancel a scheduled task at any time. Any pending
operations are canceled and the ON_TASK_CANCEL event is emitted:
To remove all scheduled tasks at once:
Changelog
See CHANGELOG.md for a list of notable changes.
License
ipl/scheduler is licensed under the terms of the MIT License.
All versions of scheduler with dependencies
ext-json Version *
dragonmantank/cron-expression Version ^3
ipl/stdlib Version >=0.15.0
psr/log Version ^1
ramsey/uuid Version ^4.2.3
react/event-loop Version ^1.4
react/promise Version ^3.3
simshaun/recurr Version ^5