{"id":33985612,"url":"https://github.com/edwardstock/forker","last_synced_at":"2026-06-05T11:31:08.113Z","repository":{"id":56975317,"uuid":"75296028","full_name":"edwardstock/forker","owner":"edwardstock","description":"PHP POSIX process manager and async ProcessPool","archived":false,"fork":false,"pushed_at":"2016-12-19T12:53:58.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-14T17:08:00.362Z","etag":null,"topics":["multithreading","phpasync"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edwardstock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-01T13:39:41.000Z","updated_at":"2016-12-09T17:35:17.000Z","dependencies_parsed_at":"2022-08-21T11:50:54.753Z","dependency_job_id":null,"html_url":"https://github.com/edwardstock/forker","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/edwardstock/forker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwardstock%2Fforker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwardstock%2Fforker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwardstock%2Fforker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwardstock%2Fforker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edwardstock","download_url":"https://codeload.github.com/edwardstock/forker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwardstock%2Fforker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33939225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multithreading","phpasync"],"created_at":"2025-12-13T04:58:10.592Z","updated_at":"2026-06-05T11:31:08.107Z","avatar_url":"https://github.com/edwardstock.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Forker\nPHP POSIX process manager and async ProcessPool\n\n[![Build Status](https://travis-ci.org/edwardstock/forker.svg?branch=master)](https://travis-ci.org/edwardstock/forker)\n\n# News\n* 1.0.2\n  * process pooling fix and added method to run process with limited count per \"now\":\n  ```php\n  \u003c?php\n  $pm = new ProcessManager();\n  $pm-\u003epool(2 /*pool size*/, true /*join processes*/);\n    \n  for($i = 0; $i \u003c 10; $i++) {\n    // when 2 jobs will added to pm queue, they will run, and cleaned after complete\n    // calling $pm-\u003erun() manually not needed\n    $pm-\u003eadd($job); \n  }\n  ```\n  \n* 1.0.1\n  * Added support for custom arguments in background funciton\n\n## Features\n* Easy to create multi-processed daemons\n* POSIX Signals dispatching\n* Serializing objects/arrays that contains closures (thx to [SuperClosure](https://github.com/jeremeamia/super_closure))\n* Uses shared memory\n* *.pid file managing\n\n## Usage examples\n#### Basic usage\n```php\n\u003c?php\nuse edwardstock\\forker\\handler\\CallbackTask;\nuse edwardstock\\forker\\ProcessManager;\n\n$updated = 0;\n\n// simple background job\n$bigTableUpdate = CallbackTask::create(function(CallbackTask $task) {\n    \n    return DB::bigQuery('UPDATE very_big_table SET field=TRUE WHERE another=FALSE'); //it's just example\n    \n})-\u003efuture(function($updatedCount, CallbackTask $task) use(\u0026$updated) {\n    \n    $updated = $updatedCount;\n    \n})-\u003eerror(function(\\Throwable $exception, CallbackTask $task){\n    \n    // handle exception occurred while DB::bigQuery()\n    Logger::log($exception);\n    \n});\n\n$processManager = new ProcessManager('/path/to/file.pid');\n$processManager\n    -\u003eadd($bigTableUpdate)\n    -\u003erun(true) // true - join to main process, if you don't have an expensive and complex logic in future method\n    -\u003ewait(); // wait while process will complete doing job\n    // if don't call wait() method, process will be detached from terminal or main process and continue to working in background\n    \necho $updated; // count of updated very_big_table\n\n```\n\nThat was just a very simple example, now more useful\n\n#### Batch usage\n\n```php\n\u003c?php\nuse edwardstock\\forker\\handler\\CallbackTask;\nuse edwardstock\\forker\\handler\\BatchTask;\nuse edwardstock\\forker\\ProcessManager;\n$toDownload = [\n    'https://google.com',\n    'https://facebook.com',\n];\n\n$results = [];\n\n\n/** @var BatchTask $downloads */\n$downloads = BatchTask::create($toDownload, function ($toDownloadItem, CallbackTask $task) {\n\n    return @file_get_contents($toDownloadItem);\n    \n})-\u003efuture(function ($sitesContent, BatchTask $task) use (\u0026$results) {\n    \n    $results = $sitesContent;\n    \n});\n\n$pm = new ProcessManager();\n$pm-\u003eadd($downloads);\n$pm-\u003erun(true)-\u003ewait(); \n\nvar_dump($results); \n// result\n// array(2) {\n//     0 =\u003e string(28) 'html_content_from_google.com'\n//     1 =\u003e string(30) 'html_content_from_facebook.com'\n// }\n\n// Order of results in this case is random, cause, for example,\n// facebook.com can be downloaded faster than google.com\n```\n\nMore examples will soon... ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwardstock%2Fforker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedwardstock%2Fforker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwardstock%2Fforker/lists"}