2017 © Pedro Peláez
 

library process

Process via pipes

image

appzz/process

Process via pipes

  • Monday, August 14, 2017
  • by CoolSwitcher
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

Process v2.0

Run cli-process in background and get output from pipes or files Works on *nix & windows (with limitations), (*1)

Install

composer require appzz/process

Basic usage

use \AppZz\CLI\Process;

chdir(realpath(__DIR__));
require_once 'vendor/autoload.php';

$cmd = 'ping google.com';

//On windows need specify pipe!!! On *nix systems you can get output from all pipes
$pr = Process::factory ($cmd, Process::STDOUT);

//Trigger for all events
$pr->trigger('all', function ($data) {
    var_dump ($data);
    echo PHP_EOL;
});

//Or you can specify separated triggers

$pr->trigger('running', function ($data) {
    //get current output
  var_dump ($data[Process::STDOUT]);
  var_dump ($data[Process::STDERR]);
    echo PHP_EOL;
});

$pr->trigger('start', function () {
    echo 'Start!!!';
    echo PHP_EOL;
});

$pr->trigger('finished', function () {
    echo 'Finished!!!';
    echo PHP_EOL;
});

//Get exitcode of process, 0 on success
$exitcode = $pr->run(true);

//Or run and go away
$pr->run(false);

//If you don't want use triggers, you can use text files
$pr->output_file('./out.txt', Process::STDOUT, false);
$pr->output_file('./err.txt', Process::STDERR, false);

//Get full output
$std_out = $pr->get_log(Process::STDOUT);
$err_log = $st->get_log(Process::STDERR);

//Or
$std_out = $pr->get_output()
$err_log = $st->get_error();

The Versions

14/08 2017

dev-master

9999999-dev https://github.com/a-pp-zz/process.git

Process via pipes

  Sources   Download

MIT

The Requires

 

by Avatar CoolSwitcher

process

14/08 2017

1.0.1

1.0.1.0 https://github.com/a-pp-zz/process.git

Process via pipes

  Sources   Download

MIT

The Requires

 

by Avatar CoolSwitcher

process

07/05 2017

1.0.0

1.0.0.0 https://github.com/a-pp-zz/process.git

Process via pipes

  Sources   Download

MIT

The Requires

 

by Avatar CoolSwitcher

process