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
$stack read-only
private
CommandStack
$stack
$sudo read-only
private
bool
$sudo
Methods
__construct()
Constructor
public
__construct(bool $sudo, CommandStack $stack) : mixed
Parameters
- $sudo : bool
-
Is sudo required?
- $stack : CommandStack
-
Command stack
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
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