PHP Classes
elePHPant
Icontem

Asynchronous Long Server Tasks: Start background tasks and query progress status

Recommend this page to a friend!
  Info   View files Example   View files View files (24)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (3)    
Last Updated Ratings Unique User Downloads Download Rankings
2015-10-06 (2 years ago) RSS 2.0 feedStarStarStarStar 73%Total: 700 All time: 4,551 This week: 664Up
Version License PHP version Categories
long-server-tasks 1.0.6MIT/X Consortium ...5.3HTTP, PHP 5, Language
Description Author

This package can start background tasks and query progress status.

There is a class that can start a background task by sending a HTTP request to a URL of a script that do the actual work on the background.

Another class can query the task progress status by polling on a given status file.

The status responses can be encoded in JSON to make it easy for processing from browser side AJAX based applications.

Innovation Award
PHP Programming Innovation award winner
September 2015
Winner


Prize: One subscription to the PDF edition of the PHP Architect magazine
Sometimes applications need to perform tasks that time a long time to complete, like for instance sending a newsletter to many subscribers.

If you send a request from the browser to execute such long server tasks, the browser will stall waiting for the job to finish.

This package provides an alternative solution that frees the browser once the long server task is started.

It also provides means to poll the server to learn about the status of progress of the long task that is still running.

Manuel Lemos
  Performance   Level  
Name: Joseluis Laso <contact>
Classes: 16 packages by
Country: Spain Spain
Age: 49
All time rank: 104820 in Spain Spain
Week rank: 177 Up6 in Spain Spain Up
Innovation award
Innovation award
Nominee: 6x

Winner: 2x

Details

asynchronous-server-tasks

A wrapper to implement asynchronous server taks in your PHP project

remember to run first `composer dumpautoload` in order to generate the appropriate autoload files

To run the example:

create a virtual a host with "your-local-name" in your development environment:

now, go to your browser and write http://your-local-name and you'll see a simple page with a button to start a new task and an area to see messages.

A little complex example

This example serves as a base to document the second part of the article on PHP Classes

Go in your browser to http://your-local-name/file-list.php

  Files folder image Files  
File Role Description
Files folder imagepublic (9 files, 2 directories)
Files folder imagesrc (4 files)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  public  
File Role Description
Files folder imageimg (4 files)
Files folder imageserver (3 files)
  Accessible without login Plain text file copy-multi.php Example new example third part
  Accessible without login Plain text file copy.php Example Example script
  Accessible without login Plain text file file-list-multi.php Example new example third part
  Accessible without login Plain text file file-list.php Example Example script
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file start-task.php Example Example script
  Accessible without login Plain text file status-copy-multi.php Example new example third part
  Accessible without login Plain text file status-copy.php Example Example script
  Accessible without login Plain text file status-task.php Example Example script

  Files folder image Files  /  public  /  img  
File Role Description
  Accessible without login Image file alert.png Icon Icon image
  Accessible without login Image file checkmark.png Icon Icon image
  Accessible without login Image file loader.gif Icon Icon image
  Accessible without login Image file progress.gif Icon Icon image

  Files folder image Files  /  public  /  server  
File Role Description
  Accessible without login Plain text file copy-file-multi.php Example new example third part
  Accessible without login Plain text file copy-file.php Example Example script
  Accessible without login Plain text file task.php Example Example script

  Files folder image Files  /  src  
File Role Description
  Plain text file CommonAbstract.php Class Class source
  Plain text file Json.php Class Class source
  Plain text file Starter.php Class Class source
  Plain text file Status.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file status-list.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:700
This week:0
All time:4,551
This week:664Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:66%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:199