{"id":19956087,"url":"https://github.com/krowinski/async","last_synced_at":"2025-05-03T19:32:38.522Z","repository":{"id":57009376,"uuid":"115051925","full_name":"krowinski/async","owner":"krowinski","description":"Run php closure asynchronously","archived":false,"fork":false,"pushed_at":"2019-12-18T10:06:10.000Z","size":17,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T20:56:17.288Z","etag":null,"topics":["async","closure","composer-packages","php","prove-of-concept"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krowinski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-21T22:16:59.000Z","updated_at":"2024-07-09T09:50:28.000Z","dependencies_parsed_at":"2022-08-21T13:10:13.527Z","dependency_job_id":null,"html_url":"https://github.com/krowinski/async","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fasync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fasync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fasync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fasync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krowinski","download_url":"https://codeload.github.com/krowinski/async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252242207,"owners_count":21717120,"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":["async","closure","composer-packages","php","prove-of-concept"],"created_at":"2024-11-13T01:30:01.359Z","updated_at":"2025-05-03T19:32:38.260Z","avatar_url":"https://github.com/krowinski.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# async\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/krowinski/async/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/krowinski/async/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/krowinski/async/badges/build.png?b=master)](https://scrutinizer-ci.com/g/krowinski/async/build-status/master)\n[![Code Coverage](https://scrutinizer-ci.com/g/krowinski/async/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/krowinski/async/?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/krowinski/async/version)](https://packagist.org/packages/krowinski/async) \n[![Latest Unstable Version](https://poser.pugx.org/krowinski/async/v/unstable)](//packagist.org/packages/krowinski/async) \n[![Total Downloads](https://poser.pugx.org/krowinski/async/downloads)](https://packagist.org/packages/krowinski/async)\n\n### How this work?\nWell its basically \"exec\" with serialised closure. \"Dressed\" in nice libs like symfony process and console.\nI serialise callable function and sent to child process by exec. To get callback I register shutdown function and wait for process to finish.\n\n### Why not pcntl ?\n- Pcntl extension fork, so you can forget using it in web applications like apache2/php-fpm etc its only for CLI\n- forks retains the parent state (for example open files) so its problematic\n\n### Problems ?\n- Calling exec is slower then fork\n- Some resource/function/data must be passed directly to closure\n\n### Some research\n- https://www.phproundtable.com/episode/asynchronous-php - good start to \"know how\" make php async\n- https://amphp.org/ - non-blocking framework for PHP\n\n### Example ?\nSure take a look - https://github.com/krowinski/async/blob/master/example/example.php\n\n### User cases (mostly some code on website that user don't need to wait for)\n- send callback\n- publish to queue amqp\n- send external analytic data\n- remove files \n- process payments\n\n### Supports M$ Windows?\nNO.\n\n### TODO \n- tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrowinski%2Fasync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrowinski%2Fasync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrowinski%2Fasync/lists"}