edwardstock / spork
This package is abandoned and no longer maintained.
No replacement package was suggested.
Asynchronous PHP
v0.4.2
2016-07-07 18:52 UTC
Requires
- php: >=5.3.0
- ext-pcntl: *
- ext-posix: *
- ext-shmop: *
- symfony/event-dispatcher: *
This package is not auto-updated.
Last update: 2023-09-17 18:39:54 UTC
README
THIS IS RENAMED FORK OF https://github.com/kriswallsmith/spork
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 });