NYCPHP Meetup

NYPHP.org

[nycphp-talk] Please wait, processing, message technique

Brent Baisley brenttech at gmail.com
Thu Jul 12 22:22:39 EDT 2007


I think you can rely on Javascript being present and enabled, with  
the all the web 2.0 stuff out there it just about has to be.

When I needed to run something long, I've run it in the background  
using the exec command. If you have command line php enabled, this  
could be just another php script. In that script you could use  
pcntl_fork to speed things up even more (multiprocessing).
I would then periodically call a script to check on the progress. Or  
the user could surf and do other things and then come back the page,  
at which time a check would be performed. O'Reilly sort of works this  
way when you want to create a PDF of  a book chapter.

If you use exec, you need to make sure it disconnects itself from the  
php process. As I recall you need to run it in the background (&) and  
send output to /dev/null. I forget if you need to do nohup also. You  
could get a bunch of things going at once, credit card payment and pi  
calcs.


On Jul 10, 2007, at 1:31 PM, Cliff Hirsch wrote:

> For long and indeterminate page processing, like connecting with a  
> credit card payment gateway or calculating pi to thousands of  
> significant digits, what is your preferred method for displaying  
> “please wait”?
>
> I see two techniques:
> Use Javascript upon form submission to display the “please wait”  
> message
> Echo a “please wait” page from the server and then do a 302  
> redirect upon completion of the scrpt.
>
> Issues:
> Not everyone uses JavaScript
> Can you issue a header redirect after echoing a “please wait”  
> message. I though headers need to be sent first. Is a 302 header  
> redirect an exception?
>
> Cliff
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070712/77bafa2d/attachment.html>


More information about the talk mailing list