ProcessContext
extends AbstractContext
in package
Tags
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"]
DEFAULT_START_TIMEOUT
private
mixed
DEFAULT_START_TIMEOUT
= 5
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
$options
private
static array<int, string>|null
$options
= 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.
$process read-only
private
Process
$process
Methods
__destruct()
public
__destruct() : mixed
__serialize()
public
final __serialize() : never
Return values
never__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : never
Parameters
- $data : array<string|int, mixed>
Return values
neverclose()
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>getPid()
Returns the PID of the process.
public
getPid() : int
Tags
Return values
intgetStderr()
Returns the STDOUT stream of the process.
public
getStderr() : ReadableResourceStream
Tags
Return values
ReadableResourceStreamgetStdin()
Returns the STDIN stream of the process.
public
getStdin() : WritableResourceStream
Tags
Return values
WritableResourceStreamgetStdout()
Returns the STDOUT stream of the process.
public
getStdout() : ReadableResourceStream
Tags
Return values
ReadableResourceStreamisClosed()
Returns whether this resource has been closed.
public
isClosed() : bool
Return values
bool —true if closed, otherwise false.
join()
public
join([Cancellation|null $cancellation = null ]) : TResult
Parameters
- $cancellation : Cancellation|null = null
Tags
Return values
TResultonClose()
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.
send()
public
send(mixed $data) : void
Parameters
- $data : mixed
signal()
Send a signal to the process.
public
signal(int $signo) : void
Parameters
- $signo : int
Tags
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
Return values
self__clone()
protected
final __clone() : mixed
receiveExitResult()
protected
receiveExitResult([Cancellation|null $cancellation = null ]) : ExitResult
Parameters
- $cancellation : Cancellation|null = null
Return values
ExitResult__construct()
private
__construct(Process $process, StreamChannel<TReceive, TSend> $ipcChannel, StreamChannel $resultChannel) : mixed
Parameters
- $process : Process
- $ipcChannel : StreamChannel<TReceive, TSend>
- $resultChannel : StreamChannel
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