PHP Classes


Recommend this page to a friend!
  Classes of Kacper Rowinski   async   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: async
Run code asynchronously using the PHP program
Author: By
Last change:
Date: 6 years ago
Size: 947 bytes


Class file image Download

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

  • - good start to "know how" make php async
  • - non-blocking framework for PHP

Example ?

Sure take a look -

Supports M$ Windows?



  • process limit
  • timeouts
  • tests