Download the PHP package crowdstar/background-processing without Composer
On this page you can find all versions of the php package crowdstar/background-processing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crowdstar/background-processing
More information about crowdstar/background-processing
Files in crowdstar/background-processing
Package background-processing
Short Description To continue processing PHP after having HTTP response sent back to the client under PHP-FPM.
License Apache-2.0
Homepage https://www.glu.com
Informations about the package background-processing
This package allows continuing processing PHP after having HTTP response sent back to the client under PHP-FPM.
PHP functions added by this package are executed after HTTP response sent back to the client but before PHP shutdown ( before any registered shutdown function is called). For detailed discussions on PHP shutdown sequence, function _fastcgi_finishrequest() and related topics, please check the post "Background Processing in PHP".
Limitations and Side Effects
This package is for PHP-FPM only. Don't try to run it under CLI, PHP built-in web server, mod_php or FastCGI since it won't work.
After sending HTTP response back to client side, background functions added continue to run and the PHP-FPM process is still running. To avoid side effects on your web server, please use this package accordingly. You may consider using some worker instances or queue servers instead. When using this package, you may consider following suggestions to minimize side effects:
- increase number of child processes in PHP-FPM.
- increase maximum execution time for PHP-FPM.
When using locks, please note that subsequent requests might block even client side has received a response from a previous request, since a lock may still be active while running background tasks in the previous request.
Installation
Sample Usage
Error Handling
By default, if a background task throws an exception, execution stops immediately and subsequent tasks will not run. You can change this behavior using the execution type setting.
Stop on Error (Default)
This is the default behavior. When a closure throws an exception, it propagates immediately and remaining closures are skipped.
Continue on Error
In this mode, all closures are executed regardless of failures. After all closures have finished, if any threw
exceptions, a single BackgroundProcessingFailedException is thrown containing all collected exceptions.
The BackgroundProcessingFailedException provides:
getMessage()— a summary like "2 background processing task(s) failed"getExceptions()— an array of all\Throwableinstances caught during executiongetPrevious()— the first exception in the list, for standard PHP exception chain traversal