IQRF PHP command executor

CommandExecutor
in package

Tool for executing commands

Table of Contents

Properties

$stack  : CommandStack
$sudo  : bool

Methods

__construct()  : mixed
Constructor
commandExist()  : bool
Checks the existence of a command
run()  : ICommand
Executes shell command and returns output
runAsync()  : ICommand
Executes the command asynchronously
createProcess()  : Process
Creates the process

Properties

Methods

commandExist()

Checks the existence of a command

public commandExist(string $cmd) : bool
Parameters
$cmd : string

Command

Return values
bool —

Is the command exists?

run()

Executes shell command and returns output

public run(string $command[, bool $needSudo = false ][, int $timeout = 60 ][, resource|string|Traversable|null $input = null ]) : ICommand
Parameters
$command : string

Command to execute

$needSudo : bool = false

Does the command need sudo?

$timeout : int = 60

Command's timeout

$input : resource|string|Traversable|null = null

Command's input

Tags
throws
RuntimeException

When process can't be launched

throws
ProcessTimedOutException

When process timed out

throws
ProcessSignaledException

When process stopped after receiving signal

Return values
ICommand —

Command entity

runAsync()

Executes the command asynchronously

public runAsync(callable(Array $type, string $data): void $callback, string $command[, bool $needSudo = false ][, int $timeout = 36000 ][, resource|string|Traversable|null $input = null ]) : ICommand
Parameters
$callback : callable(Array $type, string $data): void

Callback to run whenever there is some output available on STDOUT or STDERR

$command : string

Command to execute

$needSudo : bool = false

Does the command need sudo?

$timeout : int = 36000

Command's timeout

$input : resource|string|Traversable|null = null

Command's input

Return values
ICommand —

Command entity

createProcess()

Creates the process

private createProcess(string $cmd, bool $needSudo) : Process
Parameters
$cmd : string

Command to execute

$needSudo : bool

Does the command need sudo?

Return values
Process —

Created process


        
On this page

Search results