Download the PHP package lsr/scheduler without Composer
On this page you can find all versions of the php package lsr/scheduler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lsr/scheduler
More information about lsr/scheduler
Files in lsr/scheduler
Informations about the package scheduler
LSR Scheduler
lsr/scheduler provides Nette DI integration for the standalone Symfony Scheduler.
Scheduled jobs are application services, so their definitions and timing ship in the same repository and deployment as the application.
Requirements
- PHP
>=8.4. - Nette DI
^3.2, PSR Container^2.0and cron-expression^3.6. - Symfony Console
^8|^7, Scheduler^8|^7.4and Service Contracts^3.0. - No PHP extensions are explicitly required by this package's manifest; dependencies may add platform requirements.
- An application-owned DI bootstrap and a supervised long-running scheduler process.
lsr/consoleis suggested for loading the scheduler commands. Alternatively, register them in the application's Symfony Console application yourself.- Persistent schedule state and locking require separately installed, compatible Symfony Cache and Lock implementations.
Installation
Configuration and jobs
Register the extension in the application DI configuration:
Define a job service and its schedule:
Each job implements SchedulerJobInterface:
Use every instead of cron for interval-based jobs. Exactly one trigger must be configured:
The extension registers the scheduler:run command for lsr/console. Run it as a long-lived process:
Diagnose schedules
The extension also registers Symfony Scheduler's debug:scheduler command. It lists every configured job and attributed command with its trigger, provider name, and next run:
Pass --date='2026-01-01 00:00:00 UTC' to calculate next runs from a fixed time. Pass --all to include recurring messages whose trigger has terminated. The integration exposes its single schedule under Symfony's conventional default name.
For RoadRunner, supervise the command as a service alongside the application workers:
Persistent state and locking
Symfony Scheduler can remember the last run and prevent multiple replicas from processing the same schedule. Install compatible Symfony Cache and Lock implementations, define their services, then reference them:
The lock service must implement Symfony\Component\Lock\LockInterface; the state service must implement Symfony\Contracts\Cache\CacheInterface. If multiple containers run the scheduler, both services must use shared storage.
Scheduled work should be idempotent. Long-running or retryable work is usually best dispatched to RoadRunner jobs from the scheduled job service.
Scheduling console commands
Console commands registered as DI services can schedule themselves with Symfony Scheduler's repeatable attributes. The scheduler extension discovers them during DI compilation, just like lsr/console discovers AsCommand:
Both attributes are repeatable. Their arguments value may be a Symfony ArrayInput-style array or a command-line string:
Scheduled commands run non-interactively in the scheduler process. A non-zero exit code fails the scheduler run so the supervising process can report and restart it. The standalone integration supports the default schedule, command arguments, timezones, intervals, and jitter; Symfony Messenger transports and method-based task attributes are intentionally not supported.
Integration reference
The configuration schema and command discovery are defined in SchedulerJobContext exposes the job ID, scheduled execution time and optional next scheduled time. sleep is the scheduler's polling sleep in microseconds.
The examples above illustrate application-owned job and command definitions: replace their bodies with the application's actual work and define any shown command arguments/options. bin/console is the application's entry point, not an executable installed by this package.
SchedulerRunnerInterface provides run() and stop() for custom process integration. The bundled command requests a stop on supported SIGINT/SIGTERM signals. Job and command lifecycle hooks are available in src/Lifecycle for instrumentation.
Development
CI runs the checks below on PHP 8.4 and 8.5. From a package checkout:
composer cs checks coding style without changing files. Run composer cs:fix (or composer cbf) to apply PHP CS Fixer rules from .php-cs-fixer.php.
The suite needs no external services or persistent cache/lock implementation. Install the DOM, mbstring, XML and XMLWriter extensions for PHPUnit. The composer test script enables Xdebug coverage; the CI command explicitly disables coverage collection.
AI coding assistance
See LSR Skills for AI agent skills for working with the LSR framework.
License
Licensed under the MIT License.
All versions of scheduler with dependencies
dragonmantank/cron-expression Version ^3.6
nette/di Version ^3.2
psr/container Version ^2.0
symfony/console Version ^8|^7
symfony/scheduler Version ^8|^7.4
symfony/service-contracts Version ^3.0