1. Go to this page and download the library: Download slince/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/ */
slince / process example snippets
$process = new Slince\Process\Process(function(){
echo 'hello, my pid is ' . getmypid();
});
$process->start();
var_dump($process->isRunning()); // echo true
var_dump($process->getPid()); // will output the pid of child process
//do something other
$process->wait(); //waiting for the process to exit
$process = new Slince\Process\Process(function(){
Slince\Process\Process::current()->signal([SIGUSR1, SIGUSR2], function(){
echo 'trigger signal';
});
echo 'hello, my pid is ' . getmypid();
});
$process->start();
$process->signal(SIGUSER1);
//do something
$process->wait();
$memory = new Slince\Process\SystemV\SharedMemory();
$memory->set('foo', 'bar');
var_dump($memory->get('foo'));
$memory = new Slince\Process\SystemV\SharedMemory(__FILE__, '5M'); //Adjusts to 5m
$semaphore = new Slince\Process\SystemV\Semaphore();
$semaphore->acquire(); //Acquires a lock
// do something
$semaphore->release() //Releases a lock
$queue = new Slince\Process\SystemV\MessageQueue();
$queue->send('hello');
echo $queue->receive(); //Will output hello
$writeFifo = new Slince\Process\Pipe\WritableFifo('/tmp/test.pipe');
$writeFifo->write('some message');
$readFifo = new Slince\Process\Pipe\ReadableFifo('/tmp/test.pipe');
echo $readFifo->read();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.