2017 © Pedro Peláez
 

library async

Run php closure asynchronously

image

krowinski/async

Run php closure asynchronously

  • Saturday, January 6, 2018
  • by krowinski
  • Repository
  • 1 Watchers
  • 5 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 17 % Grown

The README.md

async

Scrutinizer Code Quality Build Status Code Coverage Latest Stable Version Latest Unstable Version Total Downloads, (*1)

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., (*2)

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, (*3)

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., (*4)

TODO

  • tests

The Versions

06/01 2018

dev-master

9999999-dev

Run php closure asynchronously

  Sources   Download

MIT

The Requires

 

by Kacper Rowinski

php async

05/01 2018

v1.0.1

1.0.1.0

Run php closure asynchronously

  Sources   Download

MIT

The Requires

 

by Kacper Rowinski

php async

31/12 2017

v1.0.0

1.0.0.0

Run php closure asynchronously

  Sources   Download

MIT

The Requires

 

by Kacper Rowinski

php async