8000 GitHub - krowinski/async: Run php closure asynchronously
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

krowinski/async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async

Scrutinizer Code Quality Build Status Code Coverage Latest Stable Version Latest Unstable Version Total Downloads

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

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

About

Run php closure asynchronously

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0