Skip to content
Execute time consuming tasks as late as possible in a request
PHP
Find file
Latest commit 8996e7c @lstrojny Migrate to new infra
Failed to load latest commit information.
build
src/Procrastinator Fixing interfaces
tests/Procrastinator Fixing interfaces
vendor Doctrine event support
.gitignore Fixing interfaces
.travis.yml Migrate to new infra
README.md Update README.md
build.xml Build infrastructure
composer.json Updating dependencies
phpunit.xml.dist Build infrastructure

README.md

Procrastinator for PHP: do stuff later

Gitter Build Status Dependency Status Average time to resolve an issue Percentage of issues still open

A few classes to help you executing complicated tasks (like sending mails) later.

Example using fastcgi_finish_request() to finish request before executing tasks

<?php
$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();
Something went wrong with that request. Please try again.