PHP code example of slava-vishnyakov / proc-runner

1. Go to this page and download the library: Download slava-vishnyakov/proc-runner 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/ */

    

slava-vishnyakov / proc-runner example snippets


$r = new ProcRunner\LocalRunner('redis-cli');

try {
    $r->send("GET test\n");
    print "Got line: " . $r->readLine() . "\n";
    $r->send("SET test 1\nGet test\n");
    print "Got line: " . $r->readLine() . "\n";
    print "Got line: " . $r->readLine() . "\n";
    print "Got line: " . $r->readLineIfAny() . "\n";

    $r->send("fds\n");
    print "Got stderr line: " . $r->readStderrLineIfAny() . "\n";
    $code = $r->close();
} catch (Exception $e) {
}

print "Got return value: " . $r->getReturnValue() . $r->readStderrLineIfAny() . "\n";