Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Experimental library for forking PHP
branch: master

Merge pull request #21 from yvann/patch-1

Fixed potential wrong $limit parameter in the child cursor if a $limit i...
latest commit a1ea635149
Kris Wallsmith authored

Build Status

Spork: PHP on a Fork


$manager = new Spork\ProcessManager();
$manager->fork(function() {
    // do something in another process!
    return 'Hello from '.getmypid();
})->then(function(Spork\Fork $fork) {
    // do something in the parent process when it's done!
    echo "{$fork->getPid()} says '{$fork->getResult()}'\n";

Example: Upload images to your CDN

Feed an iterator into the process manager and it will break the job into multiple batches and spread them across many processes.


$files = new RecursiveDirectoryIterator('/path/to/images');
$files = new RecursiveIteratorIterator($files);

$manager->process($files, function(SplFileInfo $file) {
    // upload this file
Something went wrong with that request. Please try again.