PHP Classes

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)    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 73%Total: 753 This week: 1All time: 4,449 This week: 491Up
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
Picture of Joseluis Laso
  Performance   Level  
Name: Joseluis Laso <contact>
Classes: 16 packages by
Country: Spain Spain
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
  Accessible without login Plain text file CommonAbstract.php Class Class source
  Accessible without login Plain text file Json.php Class Class source
  Accessible without login Plain text file Starter.php Class Class source
  Accessible without login 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:753
This week:1
All time:4,449
This week:491Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:66%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:212
  
For more information send a message to info at phpclasses dot org.