Documentation

ProcessContext extends AbstractContext
in package

FinalYes
Tags
template-covariant
template-covariant
template
extends

Table of Contents

Constants

DEFAULT_OPTIONS  = ["html_errors" => "0", "display_errors" => "0", "log_errors" => "1"]
DEFAULT_START_TIMEOUT  = 5
SCRIPT_PATH  = __DIR__ . "/Internal/process-runner.php"
XDEBUG_OPTIONS  = ["xdebug.mode", "xdebug.start_with_request", "xdebug.client_port", "xdebug.client_host"]

Properties

$binary  : array<int, string>|null
$ignoredSignals  : array<int, int>
$options  : array<int, string>|null
$pharCopy  : non-empty-string|null
$pharScriptPath  : non-empty-string|null
$process  : Process

Methods

__destruct()  : mixed
__serialize()  : never
__unserialize()  : never
close()  : void
Closes the resource, marking it as unusable.
getIgnoredSignals()  : array<int, int>
getPid()  : int
Returns the PID of the process.
getStderr()  : ReadableResourceStream
Returns the STDOUT stream of the process.
getStdin()  : WritableResourceStream
Returns the STDIN stream of the process.
getStdout()  : ReadableResourceStream
Returns the STDOUT stream of the process.
isClosed()  : bool
Returns whether this resource has been closed.
join()  : TResult
onClose()  : void
Registers a callback that is invoked when this resource is closed.
receive()  : TReceive
send()  : void
signal()  : void
Send a signal to the process.
start()  : self
__clone()  : mixed
receiveExitResult()  : ExitResult
__construct()  : mixed
buildOptions()  : array<int, string>
locateBinary()  : array<int, string>
unlinkExternalCopy()  : void

Constants

DEFAULT_OPTIONS

private mixed DEFAULT_OPTIONS = ["html_errors" => "0", "display_errors" => "0", "log_errors" => "1"]

SCRIPT_PATH

private mixed SCRIPT_PATH = __DIR__ . "/Internal/process-runner.php"

XDEBUG_OPTIONS

private mixed XDEBUG_OPTIONS = ["xdebug.mode", "xdebug.start_with_request", "xdebug.client_port", "xdebug.client_host"]

Properties

$binary

private static array<int, string>|null $binary = null

Cached path to located PHP binary.

$ignoredSignals

private static array<int, int> $ignoredSignals = null

$pharCopy

private static non-empty-string|null $pharCopy = null

PHAR path with a '.phar' extension.

$pharScriptPath

private static non-empty-string|null $pharScriptPath = null

External version of SCRIPT_PATH if inside a PHAR.

Methods

__unserialize()

public final __unserialize(array<string|int, mixed> $data) : never
Parameters
$data : array<string|int, mixed>
Return values
never

close()

Closes the resource, marking it as unusable.

public close() : void

Whether pending operations are aborted or not is implementation dependent.

getIgnoredSignals()

public static getIgnoredSignals() : array<int, int>
Return values
array<int, int>

isClosed()

Returns whether this resource has been closed.

public isClosed() : bool
Return values
bool

true if closed, otherwise false.

onClose()

Registers a callback that is invoked when this resource is closed.

public onClose(Closure $onClose) : void
Parameters
$onClose : Closure

receive()

public receive([Cancellation|null $cancellation = null ]) : TReceive
Parameters
$cancellation : Cancellation|null = null

Cancels waiting for the next value. Note the next value is not discarded if the operation is cancelled, rather it will be returned from the next call to this method.

Return values
TReceive

Data received.

start()

public static start(IpcHub $ipcHub, string|array<int, string> $script[, string|null $workingDirectory = null ][, array<string, string> $environment = [] ][, Cancellation|null $cancellation = null ][, string|array<int, string>|null $binary = null ][, positive-int $childConnectTimeout = self::DEFAULT_START_TIMEOUT ]) : self
Parameters
$ipcHub : IpcHub
$script : string|array<int, string>

Path to PHP script or array with first element as path and following elements options to the PHP script (e.g.: ['bin/worker.php', 'Option1Value', 'Option2Value']).

$workingDirectory : string|null = null

Working directory.

$environment : array<string, string> = []

Array of environment variables, or use an empty array to inherit from the parent.

$cancellation : Cancellation|null = null
$binary : string|array<int, string>|null = null

Path to PHP binary or array of binary path and options. Null will attempt to automatically locate the binary.

$childConnectTimeout : positive-int = self::DEFAULT_START_TIMEOUT

Number of seconds the child will attempt to connect to the parent before failing.

Tags
throws
ContextException

If starting the process fails.

Return values
self

buildOptions()

private static buildOptions() : array<int, string>
Return values
array<int, string>

locateBinary()

private static locateBinary() : array<int, string>
Return values
array<int, string>

unlinkExternalCopy()

private static unlinkExternalCopy(string|null $filepath) : void
Parameters
$filepath : string|null

        
On this page

Search results