2017 © Pedro Peláez
 

library process

Allows command line commands to be run asynchronously

image

philwaters/process

Allows command line commands to be run asynchronously

  • Saturday, April 22, 2017
  • by PhilWaters
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Process

Process allows command line commands to be run asynchronously., (*1)

Usage

$process = new Process();

$waiter = $process
    ->cwd("/working/directory") // Set the working directory
    ->cmd("find")               // Set to command to run
    ->arg(".")                  // Add an argument
    ->option("-type", "f")      // Add an option and value
    ->log("/tmp/files.log")     // Set the location of the log file
    ->async()                   // Set the process to run asynchronously
    ->run();                    // Run the command

// do some other stuff

$waiter->wait(5);               // Wait for the process to complete with a timeout of 5 seconds

Process Methods

cwd

void PhilWaters\Process\Process::cwd(string $cwd)

Sets working directory, (*2)

  • Visibility: public

Arguments

  • $cwd string - <p>Working directory</p>

cmd

\PhilWaters\Process\Process PhilWaters\Process\Process::cmd(string $cmd)

Sets the command to run, (*3)

  • Visibility: public

Arguments

  • $cmd string - <p>Command to run</p>

option

\PhilWaters\Process\Process PhilWaters\Process\Process::option(string $option, string $value, string $separator)

Adds a command option, (*4)

  • Visibility: public

Arguments

  • $option string - <p>Option</p>
  • $value string - <p>Value</p>
  • $separator string - <p>Separator</p>

arg

\PhilWaters\Process\Process PhilWaters\Process\Process::arg(string $arg)

Adds an argument, (*5)

  • Visibility: public

Arguments

  • $arg string - <p>Argument</p>

args

\PhilWaters\Process\Process PhilWaters\Process\Process::args($arg)

Adds arguments, (*6)

  • Visibility: public

Arguments

  • $arg mixed

async

\PhilWaters\Process\Process PhilWaters\Process\Process::async()

Configures the process to run asynchronously. The run method will return a waiter instead of the output., (*7)

  • Visibility: public

log

\PhilWaters\Process\Process PhilWaters\Process\Process::log(string $path, \PhilWaters\Process\number $mode)

Sets the path to a log file, (*8)

  • Visibility: public

Arguments

  • $path string - <p>Log file path</p>
  • $mode PhilWaters\Process\number - <p>Log write mode (FILE_APPEND)</p>

stdin

\PhilWaters\Process\Process PhilWaters\Process\Process::stdin(mixed $stdin, string $type)

Sets STDIN source (file or pipe), (*9)

  • Visibility: public

Arguments

  • $stdin mixed - <p>File path or value to pass to STDIN</p>
  • $type string - <p>file or pipe</p>

stdout

\PhilWaters\Process\Process PhilWaters\Process\Process::stdout(string $path, string $mode)

Sets STDOUT path, (*10)

  • Visibility: public

Arguments

  • $path string - <p>File path</p>
  • $mode string - <p>Write mode (FILE_APPEND)</p>

stderr

\PhilWaters\Process\Process PhilWaters\Process\Process::stderr(string $path, string $mode)

Sets STDERR path, (*11)

  • Visibility: public

Arguments

  • $path string - <p>File path</p>
  • $mode string - <p>Write mode (FILE_APPEND)</p>

env

\PhilWaters\Process\Process PhilWaters\Process\Process::env(array $env)

Sets array of environment variables, (*12)

  • Visibility: public

Arguments

  • $env array - <p>Array of environment variables</p>

run

\PhilWaters\Process\Waiter|array PhilWaters\Process\Process::run()

Runs the command, (*13)

  • Visibility: public

buildCommand

string PhilWaters\Process\Process::buildCommand()

Builds command string, (*14)

  • Visibility: public

Waiter Methods

wait

boolean PhilWaters\Process\Waiter::wait(\PhilWaters\Process\number $timeout)

Wait for the process to finish, (*15)

  • Visibility: public

Arguments

  • $timeout PhilWaters\Process\number - <p>Number of seconds to wait. Pass null to wait indefinitely or until PHP process exits based on max_execution_time</p>

terminate

void PhilWaters\Process\Waiter::terminate(integer $signal)

Terminates process, (*16)

  • Visibility: public

Arguments

  • $signal integer - <p>Kill signal</p>

The Versions

22/04 2017

dev-master

9999999-dev

Allows command line commands to be run asynchronously

  Sources   Download

MIT

The Development Requires

by Phil Waters

asynchronous process background escape escaping

22/04 2017

0.4.0

0.4.0.0

Allows command line commands to be run asynchronously

  Sources   Download

MIT

The Development Requires

by Phil Waters

asynchronous process background escape escaping

11/04 2017

0.3.0

0.3.0.0

Allows command line commands to be run asynchronously

  Sources   Download

MIT

The Development Requires

by Phil Waters

asynchronous process

11/04 2017

0.2.0

0.2.0.0

Allows command line commands to be run asynchronously

  Sources   Download

MIT

The Development Requires

by Phil Waters

asynchronous process

10/04 2017

0.1.0

0.1.0.0

Allows command line commands to be run asynchronously

  Sources   Download

MIT

The Development Requires

by Phil Waters

asynchronous process