lstrojny / procrastinator
Do things as late as possible in a request. Don’t let your users wait
Installs: 32 567
Dependents: 1
Suggesters: 0
Security: 0
Stars: 63
Watchers: 6
Forks: 5
Open Issues: 0
Requires
- php: >=5.3.0
- doctrine/orm: 2.*
Requires (Dev)
- lstrojny/phpunit-function-mocker: dev-master
- phpunit/phpunit: ~6
This package is auto-updated.
Last update: 2024-10-16 06:04:30 UTC
README
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();