Methods |
public
|
__construct(
string[] $command,
resource|string|null $input = null,
(Closure(FileDescriptor::OUT|FileDescriptor::ERR $fd, string $output): mixed)|null $callback = null,
?string $cwd = null,
array<string, string>|null $env = null,
?float $timeout = null,
bool $collectOutput = true,
bool $useOutputFiles = false,
)
Creates a new Process object
Creates a new Process object
|
#
|
public
static
|
withShellCommand(
string $command,
resource|string|null $input = null,
(Closure(FileDescriptor::OUT|FileDescriptor::ERR $fd, string $output): mixed)|null $callback = null,
?string $cwd = null,
array<string, string>|null $env = null,
?float $timeout = null,
bool $collectOutput = true,
bool $useOutputFiles = false,
): self
Creates a new Process object for a shell command
Creates a new Process object for a shell command
|
#
|
public
|
setInput(resource|string|null $input): $this
Pass input to the process, rewinding it before each run and making it
seekable if necessary
Pass input to the process, rewinding it before each run and making it
seekable if necessary
Throws
|
#
|
public
|
pipeInput(resource $input): $this
Pass input to the process without making it seekable or rewinding it
before each run
Pass input to the process without making it seekable or rewinding it
before each run
Throws
|
#
|
public
|
setCallback((Closure(FileDescriptor::OUT|FileDescriptor::ERR $fd, string $output): mixed)|null $callback): $this
Set the callback that receives output from the process
Set the callback that receives output from the process
Throws
|
#
|
public
|
setCwd(?string $cwd): $this
Set the initial working directory of the process
Set the initial working directory of the process
Throws
|
#
|
public
|
setEnv(array<string, string>|null $env): $this
Set the environment of the process
Set the environment of the process
Throws
|
#
|
public
|
setTimeout(?float $timeout): $this
Set the maximum number of seconds to allow the process to run
Set the maximum number of seconds to allow the process to run
Throws
|
#
|
public
|
disableOutputCollection(): $this
Disable collection of output written to STDOUT and STDERR by the process
Disable collection of output written to STDOUT and STDERR by the process
Throws
|
#
|
public
|
enableOutputCollection(): $this
Enable collection of output written to STDOUT and STDERR by the process
Enable collection of output written to STDOUT and STDERR by the process
Throws
|
#
|
public
|
runWithoutFail(
(Closure(FileDescriptor::OUT|FileDescriptor::ERR $fd, string $output): mixed)|null $callback = null,
): $this
Run the process, throwing an exception if its exit status is non-zero
Run the process, throwing an exception if its exit status is non-zero
|
#
|
public
|
run((Closure(FileDescriptor::OUT|FileDescriptor::ERR $fd, string $output): mixed)|null $callback = null): int
Run the process and return its exit status
Run the process and return its exit status
|
#
|
public
|
start((Closure(FileDescriptor::OUT|FileDescriptor::ERR $fd, string $output): mixed)|null $callback = null): $this
Run the process without waiting for it to exit
Run the process without waiting for it to exit
|
#
|
public
|
poll(bool $now = false): $this
Check the process for output and update its status
Check the process for output and update its status
If fewer than {@see Process::POLL_INTERVAL} microseconds have passed
since the process was last polled, a delay is inserted to minimise CPU
usage.
|
#
|
public
|
wait(): int
Wait for the process to exit and return its exit status
Wait for the process to exit and return its exit status
|
#
|
public
|
stop(float $timeout = 10): $this
Terminate the process if it is still running
Terminate the process if it is still running
|
#
|
public
|
isRunning(): bool
Check if the process is running
Check if the process is running
|
#
|
public
|
isTerminated(): bool
Check if the process ran and terminated
Check if the process ran and terminated
|
#
|
public
|
isTerminatedBySignal(): bool
Check if the process ran and was terminated by a signal
Check if the process ran and was terminated by a signal
|
#
|
public
|
getCommand(): string[]|string
Get the command passed to proc_open() to spawn the process
Get the command passed to proc_open() to spawn the process
|
#
|
public
|
getPid(): int
Get the process ID of the spawned process
Get the process ID of the spawned process
Throws
|
#
|
public
|
getOutput(FileDescriptor::OUT|FileDescriptor::ERR $fd = FileDescriptor::OUT): string
Get output written to STDOUT or STDERR by the process since it started
Get output written to STDOUT or STDERR by the process since it started
Throws
LogicException |
if the process has not run or if output
collection is disabled.
|
|
#
|
public
|
getNewOutput(FileDescriptor::OUT|FileDescriptor::ERR $fd = FileDescriptor::OUT): string
Get output written to STDOUT or STDERR by the process since it was last
read
Get output written to STDOUT or STDERR by the process since it was last
read
Throws
LogicException |
if the process has not run or if output
collection is disabled.
|
|
#
|
public
|
getText(FileDescriptor::OUT|FileDescriptor::ERR $fd = FileDescriptor::OUT): string
Get text written to STDOUT or STDERR by the process since it started
Get text written to STDOUT or STDERR by the process since it started
Throws
LogicException |
if the process has not run or if output
collection is disabled.
|
|
#
|
public
|
getNewText(FileDescriptor::OUT|FileDescriptor::ERR $fd = FileDescriptor::OUT): string
Get text written to STDOUT or STDERR by the process since it was last
read
Get text written to STDOUT or STDERR by the process since it was last
read
Throws
LogicException |
if the process has not run or if output
collection is disabled.
|
|
#
|
public
|
clearOutput(): $this
Forget output written by the process
Forget output written by the process
|
#
|
public
|
getExitStatus(): int
Get the exit status of the process
Get the exit status of the process
Throws
|
#
|
public
|
getStats(
): array{start_time: float, spawn_interval: float, poll_time: float, poll_count: int, read_time: float, read_count: int, stop_time: float, stop_count: int}
Get process statistics
|
#
|