1. Go to this page and download the library: Download chriskonnertz/jobs 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/ */
class ExampleJob extends ChrisKonnertz\Jobs\AbstractJob
{
protected $name = 'exampleJob';
protected $interval = 5; // Run every five minutes
public function run(int $executedAt = null)
{
echo 'Hello World!';
}
}
$cache = new ExampleCacheClass;
$jobs = new ChrisKonnertz\Jobs\Jobs($cache);
$jobs->addLazy('updateStreams', 'ExampleJob');
$jobs->run();
$hasJob = $jobs->has('exampleJob');
$job = new ExampleJob;
$jobs->add($job);
// Pass the class name:
$jobs->addLazy(\My\Example\Job::class);
// Or pass a closure:
$jobs->addLazy(function()
{
return new ExampleJob;
});
$jobs->remove('exampleJob');
$jobs->clear();
$howMany = $jobs->count();
$minutes = $jobs->remainingCoolDown();
$timestamp = $jobs->lastRunAt();
$jobs->coolDown(1); // One minute
$jobs->cacheKey('jobs.');
interface JobInterface
{
public function getName() : string; // The name (identifier) of the job
public function getActive() : bool; // Active or paused (=not executed)?
public function getInterval() : int; // The cool down time
public function run(int $executedAt = null); // The run method
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.