PHP Long Running Operations: Execute long operations split in small tasks

Recommend this page to a friend!
  Info   Screenshots   View files (30)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
72%Total: 402 All time: 6,440 This week: 353
Version License PHP version Categories
longops 0.9MIT/X Consortium ...5.2PHP 5, Utilities and Tools, Language
Description Author

This class can execute long operations split in small tasks.

It executes a portion of long operation and then exits by redirecting the current script to itself, so it executes the next step of the operation until its done.

This way each step does not exceed the PHP default execution time limit.

Each step can be executed by calling a given callback function or executing functions of an eventual sub-class of this class.

Picture of Alexander Selifonov
  Performance   Level  
Name: Alexander Selifonov is available for providing paid consulting. Contact Alexander Selifonov .
Classes: 20 packages by
Country: Russian Federation Russian Federation
Age: 58
All time rank: 522 in Russian Federation Russian Federation
Week rank: 61 6 in Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 16x

Winner: 2x

# LongOps: Helper for performing long PHP operations that exceeds max_execution_time limit

If you use "virtual server" hosting for your sites, then you know the problem.
It's name "max_execution_time". Ususaly this means "30 seconds for your PHP code", no more.
And ini_set('max_execution_time',6000) doesn't help, because your ISP won't allow it. So if you want to perform some long operation, like making non-standard data backups or import/export really big data from/to file, you have a problem.

`longOps` is a helper class that allows you to "split" your long-lasting operation to smaller "chunks" and perform the job in "step by step" manner, so every "step" never exceeds php execution limit time.
Additionally you can get the real progress bar of the whole work (not just animated gif) and get a "red button" for stopping it.
All you have to do is rewrite your "long" function so it can resume the job exactly on the point where it was "paused" in previous run. And it should check if "user asked cancel", perform cleanup operation and pass control to the "abortProcess()" class method.

![Demo process screenshot](screenshot.png)

Detailed documentation can be found in the doc folder :

["English documentation"](doc/longops.en.htm)

## Features

* Time-unlimited execution of your PHP scripts
* Job can be cancelled by user at any time (maximun waiting is equal to "time execution", configured by you for one "chunk" of processing.
* Provided javascript module  `longops.jQuery.js` makes all nesessary HTML code for client side (jQuery and jQuery.UI used to show dialog window, progress bar and send AJAX queries)

If you don't use jQuery or jQuery.UI, you'll have to write your own client-side js code.

## License

Code distributed under [MIT license](LICENSE)
  • screenshot.png
File Role Description
demo (7 files, 1 directory)
doc (2 files)
src (2 files)
LICENSE Lic. MIT License Doc. Readme

  Files  /  demo  
File Role Description
images (17 files)
   demo-backend.php Example Demo Backend (procedural)
   demo-class-backend.php Example Demo Backend (OOP)
   demo-class.php Aux. frontend demo (OOP)
   demo.php Aux. Frontend demo
   jquery-ui-custom.css Data css for UI
   jquery-ui-custom.min.js Data jQuery UI module
   jquery.min.js Data jQuery module

  Files  /  demo  /  images  
File Role Description
   animated-overlay.gif Icon for jQuery UI
   ui-bg_flat_0_aaaaaa_40x100.png Icon for jQuery UI
   ui-bg_flat_55_fbec88_40x100.png Icon for jQuery UI
   ui-bg_glass_75_d0e5f5_1x400.png Icon for jQuery UI
   ui-bg_glass_85_dfeffc_1x400.png Icon for jQuery UI
   ui-bg_glass_95_fef1ec_1x400.png Icon for jQuery UI Icon for jQuery UI
   ui-bg_gloss-wave_55_5c9ccc_500x100.png Icon for jQuery UI
   ui-bg_inset-hard_100_f5f8f9_1x100.png Icon for jQuery UI
   ui-bg_inset-hard_100_fcfdfd_1x100.png Icon for jQuery UI
   ui-icons_217bc0_256x240.png Icon for jQuery UI
   ui-icons_2e83ff_256x240.png Icon for jQuery UI
   ui-icons_469bdd_256x240.png Icon for jQuery UI
   ui-icons_6da8d5_256x240.png Icon for jQuery UI
   ui-icons_cd0a0a_256x240.png Icon for jQuery UI
   ui-icons_d8e7f3_256x240.png Icon for jQuery UI
   ui-icons_f9bd01_256x240.png Icon for jQuery UI

  Files  /  doc  
File Role Description
   helpstyles.css Data css for help
   longops.en.htm Doc. English documentation

  Files  /  src  
File Role Description
   class.longops.php Class Main backend helper class
   longops.jQuery.js Data clientside helper javascript module

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,440
This week:353
 User Ratings  
 All time

For more information send a message to info at phpclasses dot org.