ProcessHelper

class ProcessHelper extends Helper

The ProcessHelper class provides helpers to run external processes.

Methods

setHelperSet(HelperSet $helperSet = null)

Sets the helper set associated with this helper.

from Helper
HelperSet getHelperSet()

Gets the helper set associated with this helper.

from Helper
static int strlen(string $string)

Returns the length of a string, using mb_strwidth if it is available.

from Helper
static string substr(string $string, int $from, int|null $length = null)

Returns the subset of a string, using mb_substr if it is available.

from Helper
static formatTime($secs) from Helper
static formatMemory($memory) from Helper
static strlenWithoutDecoration(OutputFormatterInterface $formatter, $string) from Helper
static removeDecoration(OutputFormatterInterface $formatter, $string) from Helper
Process run(OutputInterface $output, string|array|Process $cmd, string|null $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)

Runs an external process.

Process mustRun(OutputInterface $output, string|Process $cmd, string|null $error = null, callable $callback = null)

Runs the process.

callable wrapCallback(OutputInterface $output, Process $process, callable $callback = null)

Wraps a Process callback to add debugging output.

string getName()

Returns the canonical name of this helper.

Details

setHelperSet(HelperSet $helperSet = null)

Sets the helper set associated with this helper.

Parameters

HelperSet $helperSet A HelperSet instance

HelperSet getHelperSet()

Gets the helper set associated with this helper.

Return Value

HelperSet A HelperSet instance

static int strlen(string $string)

Returns the length of a string, using mb_strwidth if it is available.

Parameters

string $string The string to check its length

Return Value

int The length of the string

static string substr(string $string, int $from, int|null $length = null)

Returns the subset of a string, using mb_substr if it is available.

Parameters

string $string String to subset
int $from Start offset
int|null $length Length to read

Return Value

string The string subset

static formatTime($secs)

Parameters

$secs

static formatMemory($memory)

Parameters

$memory

static strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)

Parameters

OutputFormatterInterface $formatter
$string

static removeDecoration(OutputFormatterInterface $formatter, $string)

Parameters

OutputFormatterInterface $formatter
$string

Process run(OutputInterface $output, string|array|Process $cmd, string|null $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)

Runs an external process.

Parameters

OutputInterface $output An OutputInterface instance
string|array|Process $cmd An instance of Process or an array of arguments to escape and run or a command to run
string|null $error An error message that must be displayed if something went wrong
callable $callback A PHP callback to run whenever there is some output available on STDOUT or STDERR
int $verbosity The threshold for verbosity

Return Value

Process The process that ran

Process mustRun(OutputInterface $output, string|Process $cmd, string|null $error = null, callable $callback = null)

Runs the process.

This is identical to run() except that an exception is thrown if the process exits with a non-zero exit code.

Parameters

OutputInterface $output An OutputInterface instance
string|Process $cmd An instance of Process or a command to run
string|null $error An error message that must be displayed if something went wrong
callable $callback A PHP callback to run whenever there is some output available on STDOUT or STDERR

Return Value

Process The process that ran

Exceptions

ProcessFailedException

See also

run()

callable wrapCallback(OutputInterface $output, Process $process, callable $callback = null)

Wraps a Process callback to add debugging output.

Parameters

OutputInterface $output An OutputInterface interface
Process $process The Process
callable $callback A PHP callable

Return Value

callable

string getName()

Returns the canonical name of this helper.

Return Value

string The canonical name

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/Console/Helper/ProcessHelper.html