1. Go to this page and download the library: Download pamkil/yii2-daemon 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/ */
pamkil / yii2-daemon example snippets
php composer.phar
namespace console\controllers;
class WatcherDaemonController extends \pamkil\daemon\controllers\WatcherDaemonController
{
/**
* @return array
*/
protected function defineJobs()
{
sleep($this->sleep);
//TODO: modify list, or get it from config, it does not matter
$daemons = [
['className' => 'OneDaemonController', 'enabled' => true],
['className' => 'AnotherDaemonController', 'enabled' => false]
];
return $daemons;
}
}
namespace console\controllers;
use \pamkil\daemon\DaemonController;
class {NAME}DaemonController extends DaemonController
{
/**
* @return array
*/
protected function defineJobs()
{
/*
TODO: return task list, extracted from DB, queue managers and so on.
Extract tasks in small portions, to reduce memory usage.
*/
}
/**
* @return jobtype
*/
protected function doJob($job)
{
/*
TODO: implement you logic
Don't forget to mark task as completed in your task source
*/
}
}