https://github.com/kriswallsmith/spork
Experimental library for forking PHP
https://github.com/kriswallsmith/spork
Last synced: 8 months ago
JSON representation
Experimental library for forking PHP
- Host: GitHub
- URL: https://github.com/kriswallsmith/spork
- Owner: kriswallsmith
- License: mit
- Created: 2012-04-10T03:31:04.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2016-03-17T13:22:16.000Z (almost 10 years ago)
- Last Synced: 2025-04-08T02:41:18.629Z (9 months ago)
- Language: PHP
- Homepage:
- Size: 372 KB
- Stars: 586
- Watchers: 33
- Forks: 52
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-php-cn - 官网
README
[](http://travis-ci.org/kriswallsmith/spork)
Spork: PHP on a Fork
--------------------
```php
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
process($files, function(SplFileInfo $file) {
// upload this file
});
```