\App\CoreModule\ModelsCommandManager

Tool for executing commands

Summary

Methods
Properties
Constants
__construct()
commandExist()
run()
runAsync()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
createProcess()
$sudo
$stack
N/A

Properties

$sudo

$sudo : bool

Type

normal — Is sudo required?

$stack

$stack : \App\CoreModule\Entities\CommandStack

Type

normal — Command stack

Methods

__construct()

__construct(bool  $sudo, \App\CoreModule\Entities\CommandStack  $stack) : mixed

Constructor

Parameters

bool $sudo

Is sudo required?

\App\CoreModule\Entities\CommandStack $stack

Command stack

Returns

mixed

commandExist()

commandExist(string  $cmd) : bool

Checks the existence of a command

Parameters

string $cmd

Command

Returns

bool —

Is the command exists?

run()

run(string  $command, bool  $needSudo = false, string|int|float|bool|resource|\Traversable|null  $input = null) : \App\CoreModule\Entities\ICommand

Executes shell command and returns output

Parameters

string $command

Command to execute

bool $needSudo

Does the command need sudo?

string|int|float|bool|resource|\Traversable|null $input

Command's input

Throws

\Symfony\Component\Process\Exception\RuntimeException

When process can't be launched

\Symfony\Component\Process\Exception\ProcessTimedOutException

When process timed out

\Symfony\Component\Process\Exception\ProcessSignaledException

When process stopped after receiving signal

Returns

\App\CoreModule\Entities\ICommand —

Command entity

runAsync()

runAsync(callable  $callback, string  $command, bool  $needSudo = false, int  $timeout = 36000, string|int|float|bool|resource|\Traversable|null  $input = null) : void

Executes the command asynchronously

Parameters

callable $callback

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

string $command

Command to execute

bool $needSudo

Does the command need sudo?

int $timeout

Command's timeout

string|int|float|bool|resource|\Traversable|null $input

Command's input

createProcess()

createProcess(string  $cmd, bool  $needSudo) : \Symfony\Component\Process\Process

Creates the process

Parameters

string $cmd

Command to execute

bool $needSudo

Does the command need sudo?

Returns

\Symfony\Component\Process\Process —

Created process