symfony-scheduler
Installation
SKILL.md
Symfony Scheduler (Symfony)
Use when
- Running recurring work (reports, cleanups, syncs) without system cron entries.
- Choosing between
RecurringMessage::every(),RecurringMessage::cron(), and a customTriggerInterface. - Splitting jobs into several named schedules with
#[AsSchedule]. - Preventing overlap or lost runs of heavy scheduled tasks.
Default workflow
- Install
symfony/scheduler, then write the message and its#[AsMessageHandler]handler. - Create a
#[AsSchedule('default')]class implementingScheduleProviderInterfaceand addRecurringMessageentries. - Pick the trigger:
every('5 minutes')orcron('0 */6 * * *'), with an explicit timezone for cron. - Add
stateful($cache)andlock($lockFactory->createLock('scheduler'))on theSchedulefor heavy tasks. - Run it with
messenger:consume scheduler_defaultunder Supervisor, one process per schedule. - Log with
PreRunEventandPostRunEvent, and test the provider throughgetRecurringMessages()andgetNextRunDate().