PHPackages                             ldkafka/yii2-scheduler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. ldkafka/yii2-scheduler

ActiveLibrary[Queues &amp; Workers](/categories/queues)

ldkafka/yii2-scheduler
======================

High-resolution cron-like job scheduler for Yii2 supporting daemon and external cron modes, queue integration, single-instance locks, and monitoring events.

1.0.5(4mo ago)1154BSD-3-ClausePHPPHP &gt;=8.0

Since Nov 8Pushed 4mo agoCompare

[ Source](https://github.com/ldkafka/yii2-scheduler)[ Packagist](https://packagist.org/packages/ldkafka/yii2-scheduler)[ RSS](/packages/ldkafka-yii2-scheduler/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (5)Used By (0)

yii2-scheduler
==============

[](#yii2-scheduler)

High-resolution cron-like job scheduler for Yii2 supporting:

- External cron mode (invoke the scheduler from system cron, typically every minute)
- Daemon mode (single long-running loop with microsecond timing and drift correction)
- Queue integration (yii2-queue) or synchronous execution
- Single-instance locks with max running time and stale lock reclamation
- Atomic distributed locks (cache add) with metadata: `{pid, host, ts}`
- Robust cron pattern parsing: wildcards, ranges, steps, lists

Installation
------------

[](#installation)

1. Require the package (after you publish it to a VCS):

```
composer require ldkafka/yii2-scheduler

```

2. Configure in your Yii2 console app (e.g. `console/config/main.php`):

```
return [
    'bootstrap' => [
        // ensure the component can bootstrap its controller
        'scheduler',
    ],
    'components' => [
        'cache' => [ /* your cache config */ ],
        'queue_scheduler' => [ /* your yii2-queue config */ ],

        'scheduler' => [
            'class' => ldkafka\scheduler\Scheduler::class,
            'config' => [
                'cache' => 'cache',            // optional; default 'cache' (uses Yii::$app->cache)
                'queue' => 'queue_scheduler',  // optional; omit to run inline synchronously
            ],
            'jobs' => require __DIR__ . '/scheduler.php',
        ],
    ],
];
```

3. Create `console/config/scheduler.php` with your jobs:

```
