PHP code example of ggedde / spry-background-process
1. Go to this page and download the library: Download ggedde/spry-background-process library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ggedde / spry-background-process example snippets
use Spry\SpryProvider\SpryBackgroundProcess;
$process = [
'controller' => 'Spry\\SpryComponent\\MyController::myMethod',
'params' => [
'id' => 123,
'name' => 'Something'
]
];
// Run the Process and return its unix ID
$process_id = SpryBackgroundProcess::create($process);
// Check to see if the process is still running
if(SpryBackgroundProcess::isRunning($process_id))
{
// It is still running
}
else
{
// It has finished
}
// Stop a Process by unix ID
SpryBackgroundProcess::stop($process_id);
$process = [
'controller' => 'Spry\\SpryComponent\\MyController::myMethod',
'hash' => true,
'params' => [
'id' => 123,
'name' => 'Something'
]
];
// Run the Process and return its unix ID and Hash
$process_data = SpryBackgroundProcess::create($process);
// Check to see if the process is still running
if(SpryBackgroundProcess::isRunning($process_data['pid'], $process_data['hash']))
{
// It is still running
}
else
{
// It has finished
}
// Stop a Process by unix ID and Hash
SpryBackgroundProcess::stopIfIsRunning($process_data['pid'], $process_data['hash']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.