background process with PHP
$lp = new LongProcess($processKey);Process key is important to identify process
$lp->key($processKey); // set
$lp->key(); // getA directory stores the progress files (Default: 'tmp')
$lp->folderPath($dir); // set
$lp->folderPath(); // getUrl of progress folder (Default: 'tmp')
$lp->folderUrl($url); // set
$lp->folderUrl(); // getLimits the maximum execution time (Default: 0)
$lp->timeLimit($timeLimit); // set
$lp->timeLimit(); // getUsed to monitor the progress (Default: 1)
$lp->taskWeight($taskWeight); // set
$lp->taskWeight(); // getIf true, process will be killed when task encounter exception (Default: false)
$lp->killProcess($bool); // set
$lp->killProcess(); // getPath of progress file
$lp->file();Url of progress file
$lp->fileUrl();Check the running status of process
$lp->isRunning();While the background process started, any output would not be displayed. The output callback is executed before the background process. It can output any information. (Default: '{"key":(processKey),"progress":(fileUrl)}')
$lp->output($callback, $arguments);Add new task to the background process
$lp->addTask($callback, $arguments);Add message to progress file within a task
$lp->taskMessage($message);Get array of progress files
$lp->checkRunningProgress();Get progress by process key
$lp->checkProgress($processKey);Start running the process
$lp->run();$lp = new LongProcess('1');
function task() {
sleep(1); // simulate long process
}
$lp->addTask('task');
$lp->run();Copyright (c) 2014 php-long-process
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- 2014-01-10 v0.9.2 taskMessage can be called multiple times.
- 2014-01-09 v0.9.1 First release.