PHP code example of neutron / tip-top

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

    

neutron / tip-top example snippets


$clock = new Clock();
// triggers a callback every second
$timer = $clock->addPeriodicTimer(1, function ($timer) {
    echo "BOOM ! I'm triggered every second !\n";
});

use Neutron\TipTop\Clock;

// mandatory for the clock to work
declare(ticks=1);

$clock = new Clock();

// triggers a callback every second
$timer = $clock->addPeriodicTimer(1, function ($timer) {
    echo "BOOM ! I'm triggered every second !\n";
});

// triggers a callback in 5 second
$timer = $clock->addTimer(5, function ($timer) {
    echo "BOOM ! I was planned 5 seconds ago !\n";
});

// removes all timers
$clock->clear();

use Neutron\TipTop\Clock;

// mandatory for the clock to work
declare(ticks=1);

$clock = new Clock();

$timer = $clock->addPeriodicTimer(1, function ($timer) {
    if ($stop) {
        $timer->cancel();
    }
});

use Neutron\TipTop\Clock;

// mandatory for the clock to work
declare(ticks=1);

$clock = new Clock();

$timer = $clock->addPeriodicTimer(1, function ($timer) { echo "Hello"; });
$timer = $clock->addPeriodicTimer(1, function ($timer) { echo "Hello World"; });

// removes all timers
$clock->clear();

use Neutron\TipTop\Clock;

// mandatory for the clock to work
declare(ticks=1);

$clock = new Clock();

// echoes three times
$clock->addPeriodicTimer(1, function (signature) {
    echo "The block method blocks \n";
}, 3);

$clock->block();
echo "This line will be blocked until last timer executes