class ProcessBuilder

Process builder.

Methods

__construct(array $arguments = array())

Constructor.

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

Creates a process builder instance.

add(string $argument)

Adds an unescaped argument to the command string.

setPrefix(string|array $prefix)

Adds a prefix to the command string.

setArguments(array $arguments)

Sets the arguments of the process.

setWorkingDirectory(null|string $cwd)

Sets the working directory.

inheritEnvironmentVariables(bool $inheritEnv = true)

Sets whether environment variables will be inherited or not.

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

Sets an environment variable.

addEnvironmentVariables(array $variables)

Adds a set of environment variables.

setInput(mixed $input)

Sets the input of the process.

setTimeout(float|null $timeout)

Sets the process timeout.

setOption(string $name, string $value)

Adds a proc_open option.

disableOutput()

Disables fetching output and error output from the underlying process.

enableOutput()

Enables fetching output and error output from the underlying process.

getProcess()

Creates a Process instance and returns it.

Details

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

Constructor.

Parameters

array $arguments An array of arguments

at line 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 line 63
ProcessBuilder add(string $argument)

Adds an unescaped argument to the command string.

Parameters

string $argument A command argument

Return Value

ProcessBuilder

at line line 79
ProcessBuilder 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

ProcessBuilder

at line line 96
ProcessBuilder setArguments(array $arguments)

Sets the arguments of the process.

Arguments must not be escaped. Previous arguments are removed.

Parameters

array $arguments

Return Value

ProcessBuilder

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

Sets the working directory.

Parameters

null|string $cwd The working directory

Return Value

ProcessBuilder

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

Sets whether environment variables will be inherited or not.

Parameters

bool $inheritEnv

Return Value

ProcessBuilder

at line line 142
ProcessBuilder setEnv(string $name, null|string $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
null|string $value The variable value

Return Value

ProcessBuilder

at line line 160
ProcessBuilder 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

ProcessBuilder

at line line 176
ProcessBuilder setInput(mixed $input)

Sets the input of the process.

Parameters

mixed $input The input as a string

Return Value

ProcessBuilder

Exceptions

InvalidArgumentException In case the argument is invalid

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

Sets the process timeout.

To disable the timeout, set this value to null.

Parameters

float|null $timeout

Return Value

ProcessBuilder

Exceptions

InvalidArgumentException

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

Adds a proc_open option.

Parameters

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

Return Value

ProcessBuilder

at line line 233
ProcessBuilder disableOutput()

Disables fetching output and error output from the underlying process.

Return Value

ProcessBuilder

at line line 245
ProcessBuilder enableOutput()

Enables fetching output and error output from the underlying process.

Return Value

ProcessBuilder

at line line 259
Process getProcess()

Creates a Process instance and returns it.

Return Value

Process

Exceptions

LogicException In case no arguments have been provided