Asynchronous PHP

Maintainers

👁 kriswallsmith

Package info

github.com/kriswallsmith/spork

pkg:composer/kriswallsmith/spork

Statistics

Installs: 958 825

Dependents: 18

Suggesters: 12

Stars: 586

Open Issues: 24

v0.3 2015-05-18 19:16 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 530fcf57fce4d54806288547b22aa8dcbb4b6c96

This package is auto-updated.

Last update: 2026-05-29 01:07:25 UTC


README

👁 Build Status

Spork: PHP on a Fork

<?php

$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.

<?php

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

$manager->process($files, function(SplFileInfo $file) {
 // upload this file
});