class ProcessBuilder

deprecated since version 3.4, to be removed in 4.0. Use the Process class instead.

Methods

__construct(array $arguments = array())

No description

static ProcessBuilder
create(array $arguments = array())

Creates a process builder instance.

$this
add(string $argument)

Adds an unescaped argument to the command string.

$this
setPrefix(string|array $prefix)

Adds a prefix to the command string.

$this
setArguments(array $arguments)

Sets the arguments of the process.

$this
setWorkingDirectory(string|null $cwd)

Sets the working directory.

$this
inheritEnvironmentVariables(bool $inheritEnv = true)

Sets whether environment variables will be inherited or not.

$this
setEnv(string $name, string|null $value)

Sets an environment variable.

$this
addEnvironmentVariables(array $variables)

Adds a set of environment variables.

$this
setInput(resource|string|int|float|bool|Traversable|null $input)

Sets the input of the process.

$this
setTimeout(float|null $timeout)

Sets the process timeout.

$this
setOption(string $name, string $value)

Adds a proc_open option.

$this
disableOutput()

Disables fetching output and error output from the underlying process.

$this
enableOutput()

Enables fetching output and error output from the underlying process.

getProcess()

Creates a Process instance and returns it.

Details

at line 39
__construct(array $arguments = array())

Parameters

array $arguments An array of arguments

at line 51
static ProcessBuilder create(array $arguments = array())

Creates a process builder instance.

Parameters

array $arguments An array of arguments

Return Value

ProcessBuilder

at line 63
$this add(string $argument)

Adds an unescaped argument to the command string.

Parameters

string $argument A command argument

Return Value

$this

at line 79
$this setPrefix(string|array $prefix)

Adds a prefix to the command string.

The prefix is preserved when resetting arguments.

Parameters

string|array $prefix A command prefix or an array of command prefixes

Return Value

$this

at line 96
$this setArguments(array $arguments)

Sets the arguments of the process.

Arguments must not be escaped. Previous arguments are removed.

Parameters

array $arguments

Return Value

$this

at line 110
$this setWorkingDirectory(string|null $cwd)

Sets the working directory.

Parameters

string|null $cwd The working directory

Return Value

$this

at line 124
$this inheritEnvironmentVariables(bool $inheritEnv = true)

Sets whether environment variables will be inherited or not.

Parameters

bool $inheritEnv

Return Value

$this

at line 142
$this setEnv(string $name, string|null $value)

Sets an environment variable.

Setting a variable overrides its previous value. Use null to unset a defined environment variable.

Parameters

string $name The variable name
string|null $value The variable value

Return Value

$this

at line 160
$this addEnvironmentVariables(array $variables)

Adds a set of environment variables.

Already existing environment variables with the same name will be overridden by the new values passed to this method. Pass null to unset a variable.

Parameters

array $variables The variables

Return Value

$this

at line 176
$this setInput(resource|string|int|float|bool|Traversable|null $input)

Sets the input of the process.

Parameters

resource|string|int|float|bool|Traversable|null $input The input content

Return Value

$this

Exceptions

InvalidArgumentException In case the argument is invalid

at line 194
$this setTimeout(float|null $timeout)

Sets the process timeout.

To disable the timeout, set this value to null.

Parameters

float|null $timeout

Return Value

$this

Exceptions

InvalidArgumentException

at line 221
$this setOption(string $name, string $value)

Adds a proc_open option.

Parameters

string $name The option name
string $value The option value

Return Value

$this

at line 233
$this disableOutput()

Disables fetching output and error output from the underlying process.

Return Value

$this

at line 245
$this enableOutput()

Enables fetching output and error output from the underlying process.

Return Value

$this

at line 259
Process getProcess()

Creates a Process instance and returns it.

Return Value

Process

Exceptions

LogicException In case no arguments have been provided