Home

Awesome

jphp-process-ext

Process API for jphp, more advanced and powerful!

Features:

Requires

How to install

jppm add jphp-process-ext

How to use?

  1. Get process handle of a process instance:
use php\lang\Process;
use process\ProcessHandle;

$process = new Process(['cmd', '/c', 'calc.exe']);
$processHandle = new ProcessHandle($process->start());

echo "PID: ", $processHandle->pid(), "\n";
echo "Info: ", print_r($processHandle->info(), true), "\n";
  1. How to destroy process?
$process = new Process(['cmd', '/c', 'calc.exe']);
$processHandle = new ProcessHandle($process->start());

$success = $processHandle->destroy();
  1. How to get children processes?
$processHandles = $processHandle->children();

foreach ($processHandles as $handle) {
   var_dump($handle->info());
}
  1. How to get all process handles?
$allProcesses = ProcessHandle::allProcesses();
  1. How to get process handle by pid?
$pid = 13894;
$processHandler = ProcessHandle::ofPid($pid);
  1. How to get process handle of current process?
$processHandler = ProcessHandle::current();