PHP code example of lstrojny / procrastinator

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

    

lstrojny / procrastinator example snippets



$procrastinator = new \Procrastinator\DeferralManager(
    new \Procrastinator\Scheduler\OnRegisterShutdownScheduler(),
    new \Procrastinator\Executor\Decorator\PhpFpmExecutorDecorator(
        new \Procrastinator\Executor\SingleThreadExecutor()
    )
);

// The rough way
$procrastinator->register(
    new \Procrastinator\Deferred\CallbackDeferred(
        'some name',
        function() {sleep(10);}
    )
);

// Or use the more convenient builder interface
$procrastinator->register(
    $procrastinator
        ->newDeferred()
        ->name('some other name')
        ->call(function() {sleep(10);}
        ->build()
);

$procrastinator->schedule();