1. Go to this page and download the library: Download ldkafka/yii2-scheduler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ldkafka / yii2-scheduler example snippets
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' =>
namespace common\jobs;
use ldkafka\scheduler\ScheduledJob;
use Yii;
class ExampleJob extends ScheduledJob
{
public function execute($queue = null)
{
Yii::info('ExampleJob executed', 'scheduler');
// do work
return true; // success
}
}