{"id":20678896,"url":"https://github.com/phpgt/daemon","last_synced_at":"2025-04-19T23:45:21.225Z","repository":{"id":49532967,"uuid":"173779151","full_name":"phpgt/Daemon","owner":"phpgt","description":"Background process execution.","archived":false,"fork":false,"pushed_at":"2024-09-12T13:29:15.000Z","size":877,"stargazers_count":0,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T23:45:15.264Z","etag":null,"topics":["background-jobs","background-task","exec","pipes","process","subshell","windows"],"latest_commit_sha":null,"homepage":"https://www.php.gt/daemon","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpgt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["phpgt"]}},"created_at":"2019-03-04T16:17:36.000Z","updated_at":"2024-09-12T13:29:59.000Z","dependencies_parsed_at":"2024-05-08T18:36:36.885Z","dependency_job_id":"0bbbc44c-4168-4c7f-b850-9d2376e62d14","html_url":"https://github.com/phpgt/Daemon","commit_stats":{"total_commits":54,"total_committers":2,"mean_commits":27.0,"dds":0.05555555555555558,"last_synced_commit":"4732e179c600d0a020cc4113c71ed21582b9aeea"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FDaemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FDaemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FDaemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FDaemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpgt","download_url":"https://codeload.github.com/phpgt/Daemon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249830845,"owners_count":21331357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["background-jobs","background-task","exec","pipes","process","subshell","windows"],"created_at":"2024-11-16T21:22:58.781Z","updated_at":"2025-04-19T23:45:21.209Z","avatar_url":"https://github.com/phpgt.png","language":"PHP","funding_links":["https://github.com/sponsors/phpgt"],"categories":[],"sub_categories":[],"readme":"Background process execution.\n=============================\n\nExecute background processes asynchronously using an object oriented process pool.\n\n***\n\n\u003ca href=\"https://github.com/PhpGt/Daemon/actions\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/daemon-build.svg\" alt=\"Build status\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://app.codacy.com/gh/PhpGt/Daemon\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/daemon-quality.svg\" alt=\"Code quality\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://app.codecov.io/gh/PhpGt/Daemon\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/daemon-coverage.svg\" alt=\"Code coverage\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/PhpGt/Daemon\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/daemon-version.svg\" alt=\"Current version\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.php.gt/deaemon\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/daemon-docs.svg\" alt=\"PHP.G/Daemon documentation\" /\u003e\n\u003c/a\u003e\n\n## Example usage\n\n```php\n\u003c?php\nuse Gt\\Daemon\\Process;\nuse Gt\\Daemon\\Pool;\n\n// Create three long-running processes:\n$pingProcess = new Process(\"ping google.com\");\n$infiniteProcess = new Process(\"while true; do echo 'background...'; sleep 3; done\");\n$dateProcess = new Process(\"while true; do echo $(date -d now); sleep 2; done\");\n\n// Add all three processes to a pool:\n$pool = new Pool();\n$pool-\u003eadd(\"Ping\", $pingProcess);\n$pool-\u003eadd(\"Loop\", $infiniteProcess);\n$pool-\u003eadd(\"Date\", $dateProcess);\n\n// Start the execution of all processes:\n$pool-\u003eexec();\n\n// While processes are running, write their output to the terminal:\ndo {\n\techo $pool-\u003eread();\n\t// Sleep to avoid hogging the CPU.\n\tsleep(1);\n}\nwhile($pool-\u003enumRunning() \u003e 0);\n```\n\nOutputs something similar to:\n\n```\n[Ping] PING google.com (172.217.169.78) 56(84) bytes of data.\n[Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=1 ttl=52 time=8.78 ms\n[Loop] background...\n[Date] Mon 19 Aug 09:58:54 BST 2019\n[Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=2 ttl=52 time=8.75 ms\n[Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=3 ttl=52 time=8.75 ms\n[Date] Mon 19 Aug 09:58:56 BST 2019\n[Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=4 ttl=52 time=8.75 ms\n[Loop] background...\n[Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=5 ttl=52 time=8.80 ms\n[Date] Mon 19 Aug 09:58:58 BST 2019\n```\n\nNotice how the date process is only set to loop three times, and after it is complete the other two infinite processes continue to run.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpgt%2Fdaemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpgt%2Fdaemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpgt%2Fdaemon/lists"}