Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of running php jobs in background #15

Open
GoogleCodeExporter opened this issue Aug 28, 2015 · 0 comments
Open

Example of running php jobs in background #15

GoogleCodeExporter opened this issue Aug 28, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

GoogleCodeExporter commented Aug 28, 2015

When developing a desktop application there might be the need to run a PHP script that does some heavy lifting, thus executes for a significant amount of time, for that we need to embed a multi-threaded
web server (Issue 14) in the first place.

Useful php functions / php.ini options:

  • ignore_user_abort()
  • set_time_limit(0)

Issue with running background php jobs when page is refreshed was reported in this topic: https://groups.google.com/d/topic/phpdesktop/a-LHbSWbbDQ/discussion

Issue #31 describes a plan for implementing LaunchProcess function and exposing it via Javascript API. Processes launched using this function would be guaranteed to run for app's lifetime and terminate when app exits.

OLD INFO:

One way for such an API would be to run php scripts asynchronously
in the background using for example CURL library. It would be nice
if such API provided a way to provide callbacks, so that you can be notified
when the background job finished executing, such callback
might be an URL to a php script or a Javascript function that will
get called in the browser, though javascript callback might be hard
to implement and it is probably only possible if we go with direct
PHP API calls (Issue 3).

Another approach is to create a javascript API for executing php jobs
in background using XMLHttpRequest, this way browser gets notified when
a job has finished and it will play nicely with an embedded web-server.

It is also possible to display a progress of a time consuming task without
the need of using ajax techniques, by disabling output buffering and flushing
a string that calls a javascript function that updates the progresss bar, see
this post on the PHP Desktop Forum:

https://groups.google.com/d/msg/phpdesktop/EoJchr65dk8/OZryJKp_Fy4J

I think that all we need is some simple example using XMLHttpRequest
object and another one using curl library (or just file_get_contents
and fetching partial content).

Original issue reported on code.google.com by czarek.t...@gmail.com on 15 Jan 2013 at 7:09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants