PHP code example of liip / process-manager

1. Go to this page and download the library: Download liip/process-manager 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/ */

    

liip / process-manager example snippets



use Liip\ProcessManager\ProcessManager;
use Liip\ProcessManager\PidFile;

// run a process in the back ground
$processManager = new ProcessManager();
$pid = $processManager->execProcess('sleep 10m');
$processManager->isProcessRunning($pid)
$processManager->killProcess($pid);

// to set log location instead of routing it to /dev/null by default
$processManager = new ProcessManager('/path/to/logfile');
$pid = $processManager->execProcess('sleep 10m');

// acquire a lock via a pid file
$lock = new PidFile(new ProcessManager(), '/tmp/foobar');
$lock->acquireLock();
$pid = $lock->execProcess('sleep 10m');
// set the PID which should be locked on
$lock->setPid(getmypid());
$lock->releaseLock();