PHP code example of coff / ticker

1. Go to this page and download the library: Download coff/ticker 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/ */

    

coff / ticker example snippets


$ticker = new Ticker();

$ticker->addTick(new Tick(Time::SECOND, 1, function () {
    // do it every second
}));

$ticker->addTick(new Tick(Time::SECOND, 5, function () {
    // do it every 5 seconds
}));

$ticker->addTick(new Tick(Time::MINUTE, 1, function() {
    // do it every minute
}));

$ticker->loop();


$tick = new class extends Tick {

    protected $everyN = 1;
    protected $interval = Time::HOUR;

    public function run() 
    {
        // hourly task
    }
}

$ticker = new Ticker();
$ticker->addTick($tick);
$ticker->loop();