jc-it / yii2-job-queue-recurring
Job Queue implementation - Recurring extension.
Installs: 74
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jc-it/yii2-job-queue-recurring
Requires
- php: >=8.3
- dragonmantank/cron-expression: ^3.4
- jc-it/yii2-job-queue: ^3.0
This package is auto-updated.
Last update: 2025-10-10 13:55:59 UTC
README
This extension provides a package that implements a way to store recurring jobs in the database for the yii2 job queue.
$ composer require jc-it/yii2-job-queue-recurring
or add
"jc-it/yii2-job-queue-recurring": "<latest version>"
to the require section of your composer.json file.
Configuration
A possible implementation for recurring jobs has been added. This implementation stores the recurrence using the Cron notation and an Active Record model. It can easily be extended by creating own implementations for the AR model and Handler.
To use the recurring jobs with the implementation as provided by the package:
- Add
\JCIT\jobqueue\migrationsto your migration namespaces, or extend a new migration from the migration in the package and run them - Register
\JCIT\jobqueue\jobs\RecurringJob::classand\JCIT\jobqueue\jobHandlers\RecurringHandler::classin theContainerMapLocator(as shown in the configuration) - Add the recurring action to the controller:
public function actions(): array { return [ 'daemon' => \JCIT\jobqueue\actions\DaemonAction::class, 'recurring' => \JCIT\jobqueue\actions\RecurringJobAction::class, ]; }
- Run action, i.e.
./yii job-queue/recurring - Add a recurring job to the database i.e.
$jobFactory = \Yii::createObject(\JCIT\jobqueue\interfaces\JobFactoryInterface::class); $job = new \JCIT\jobqueue\models\activeRecord\RecurringJob([ 'name' => 'Hello world job', 'description' => 'Say hello to the world every minute', 'job_data' => $jobFactory->saveToArray(new \JCIT\jobqueue\jobs\HelloJob('world')), 'cron' => '* * * * *' ]); $job->save();