Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krowinski/async
Run php closure asynchronously
https://github.com/krowinski/async
async closure composer-packages php prove-of-concept
Last synced: 1 day ago
JSON representation
Run php closure asynchronously
- Host: GitHub
- URL: https://github.com/krowinski/async
- Owner: krowinski
- Created: 2017-12-21T22:16:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-18T10:06:10.000Z (almost 5 years ago)
- Last Synced: 2024-08-19T23:08:48.977Z (3 months ago)
- Topics: async, closure, composer-packages, php, prove-of-concept
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# async
[![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)
[![Build Status](https://scrutinizer-ci.com/g/krowinski/async/badges/build.png?b=master)](https://scrutinizer-ci.com/g/krowinski/async/build-status/master)
[![Code Coverage](https://scrutinizer-ci.com/g/krowinski/async/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/krowinski/async/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/krowinski/async/version)](https://packagist.org/packages/krowinski/async)
[![Latest Unstable Version](https://poser.pugx.org/krowinski/async/v/unstable)](//packagist.org/packages/krowinski/async)
[![Total Downloads](https://poser.pugx.org/krowinski/async/downloads)](https://packagist.org/packages/krowinski/async)### How this work?
Well its basically "exec" with serialised closure. "Dressed" in nice libs like symfony process and console.
I serialise callable function and sent to child process by exec. To get callback I register shutdown function and wait for process to finish.### Why not pcntl ?
- Pcntl extension fork, so you can forget using it in web applications like apache2/php-fpm etc its only for CLI
- forks retains the parent state (for example open files) so its problematic### Problems ?
- Calling exec is slower then fork
- Some resource/function/data must be passed directly to closure### Some research
- https://www.phproundtable.com/episode/asynchronous-php - good start to "know how" make php async
- https://amphp.org/ - non-blocking framework for PHP### Example ?
Sure take a look - https://github.com/krowinski/async/blob/master/example/example.php### User cases (mostly some code on website that user don't need to wait for)
- send callback
- publish to queue amqp
- send external analytic data
- remove files
- process payments### Supports M$ Windows?
NO.### TODO
- tests