job-runner / job-runner
Installs: 23 743
Dependents: 3
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 0
Open Issues: 2
Requires
- php: ~8.2.0 || ~8.3.0 || ~8.4.0
- dragonmantank/cron-expression: ^3.4.0
- symfony/clock: ^6.3 || ^7.0
- symfony/lock: ^5.0 || ^6.0 || ^7.0
- symfony/process: ^5.0 || ^6.0 || ^7.0
Requires (Dev)
- doctrine/coding-standard: ^12.0
- phpstan/phpstan: ^2.0.1
- phpunit/phpunit: ^11.4.3
This package is auto-updated.
Last update: 2025-06-20 12:01:21 UTC
README
Install
composer require job-runner/job-runner
This cron job manager is inspired by https://github.com/jobbyphp/jobby but with various improvements
- It use
symfony/locker
so you can use the power of it - It use
symfony/process
instead ofexec
- It lock by task and not for all task
- It has an event manager
Simple Sample
<?php declare(strict_types=1); use JobRunner\JobRunner\Job\CliJob; use JobRunner\JobRunner\Job\JobList; use JobRunner\JobRunner\CronJobRunner; require 'vendor/autoload.php'; $jobList = new JobList(); $jobList->push(new CliJob('php ' . __DIR__ . '/tutu.php', '* * * * *')); $jobList->push(new CliJob('php ' . __DIR__ . '/tutu2.php', '* * * * *')); CronJobRunner::create()->run($jobList); // or CronJobRunner::create()->run(JobList::fromArray([ [ 'command' => 'php ' . __DIR__ . '/tutu.php', 'cronExpression' => '* * * * *', ],[ [ 'command' => 'php ' . __DIR__ . '/tutu2.php', 'cronExpression' => '* * * * *', ] ]));
Using you own locker storage
<?php declare(strict_types=1); use JobRunner\JobRunner\Job\CliJob; use JobRunner\JobRunner\Job\JobList; use JobRunner\JobRunner\CronJobRunner; require 'vendor/autoload.php'; $mySymfonyLockerStore = new \Symfony\Component\Lock\Store\MongoDbStore(); $jobList = new JobList(); $jobList->push(new CliJob('php ' . __DIR__ . '/tutu.php', '* * * * *')); CronJobRunner::create()->withPersistingStore($mySymfonyLockerStore)->run($jobList);
Listening to events
there is various of event you can listen
JobRunner\JobRunner\Event\JobSuccessEvent
JobRunner\JobRunner\Event\JobFailEvent
JobRunner\JobRunner\Event\JobIsLockedEvent
JobRunner\JobRunner\Event\JobNotDueEvent
JobRunner\JobRunner\Event\JobStartEvent
Plugins
- job-runner/psr-log-adapter Adapter to logs events in psr/log
- job-runner/symfony-console-adapter Adapter to logs events in symfony/console
- job-runner/symfony-notifier-adapter Adapter to logs events in symfony/notifier