Login   Register  
PHP Classes
elePHPant
Icontem

Async programming in PHP on Windows

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PHP Classes blog  >  Accelerate scripts ru...  >  All threads  >  Async programming in PHP on Windows  >  (Un) Subscribe thread alerts  
Subject:Async programming in PHP on Windows
Summary:Multiple, "threaded" asynchronous, IPC and Windows. All with PHP
Messages:3
Author:Richard Quadling
Date:2010-10-28 12:32:33
Update:2010-11-21 20:05:42
 

  1. Async programming in PHP on Windows   Reply   Report abuse  
Picture of Richard Quadling
Richard Quadling
2010-10-28 16:19:09
Hi.

I'm just doing something similar for Windows. I'm using Windows SCM with PHP's win32service extension to create a windows service written in PHP.

Add to this, I'm using ...

$WshShell = new COM("WScript.Shell");
$WshShell->Run(__FILE__ . " task $Task", 9, false);

to allow _this_ script to act as a task controller, allowing it to launch scripts and NOT have to wait for them to finish execution.

And finally, using PHP's wincache extension to allow communication between the scripts.

OK. It seems daft, but I can use the same code I need in my web/cli work in the unattended services.

Add to that, the sysops can start/stop these services in exactly the same way as all the other services. With no extra instructions. They can also monitor them using the same tools they use for monitoring all/any of the windows services.

A win/win for all!

And an interesting project for me.

  2. Re: Async programming in PHP on Windows   Reply   Report abuse  
Picture of Gaetano Giunta
Gaetano Giunta
2010-11-21 00:19:45 - In reply to message 1 from Richard Quadling
Hello Richard. While I agree that there are many ways to achieve async programming in php, they're either hackish or convolute, or quite unportable. A language construct always available would go a long way towards making php async programming commonpractice.

  3. Re: Async programming in PHP on Windows   Reply   Report abuse  
Picture of Richard Quadling
Richard Quadling
2010-11-21 20:05:42 - In reply to message 2 from Gaetano Giunta
Ha. I think my solution is all three! But until PHP supports REAL threading and has a native IPC mechanism, we are going to be stuck with unportable convoluted hacks. But my code is clearly documented, using easily understandable patterns, so, hopefully, it is understandable by at least me in a years time.