Documentation

CurlMultiHandler
in package

Returns an asynchronous response using curl_multi_* functions.

When using the CurlMultiHandler, custom curl options can be specified as an associative array of curl option constants mapping to values in the curl key of the provided request options.

Tags
final

Table of Contents

$_mh  : resource|CurlMultiHandle
$active  : int
$delays  : array<int, float>
$factory  : CurlFactoryInterface
$handles  : array<string|int, mixed>
$options  : array<string|int, mixed>
$selectTimeout  : int
__construct()  : mixed
This handler accepts the following options:
__destruct()  : mixed
__get()  : resource|CurlMultiHandle
__invoke()  : PromiseInterface
execute()  : void
Runs until all outstanding connections have completed.
tick()  : void
Ticks the curl event loop.
addRequest()  : void
cancel()  : bool
Cancels a handle from sending and removes references to it.
processMessages()  : void
timeToNext()  : int

Properties

$_mh

public resource|CurlMultiHandle $_mh

Internal use only. Lazy loaded multi-handle.

$active

private int $active = 0

Will be higher than 0 when curl_multi_exec is still running.

$delays

private array<int, float> $delays = []

An array of delay times, indexed by handle id in addRequest.

Tags
see
CurlMultiHandler::addRequest

$handles

private array<string|int, mixed> $handles = []

Request entry handles, indexed by handle id in addRequest.

Tags
see
CurlMultiHandler::addRequest

$options

private array<string|int, mixed> $options = []

An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()

Methods

__construct()

This handler accepts the following options:

public __construct([array<string|int, mixed> $options = [] ]) : mixed
  • handle_factory: An optional factory used to create curl handles
  • select_timeout: Optional timeout (in seconds) to block before timing out while selecting curl handles. Defaults to 1 second.
  • options: An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()
Parameters
$options : array<string|int, mixed> = []
Return values
mixed

__get()

public __get(string $name) : resource|CurlMultiHandle
Parameters
$name : string
Tags
throws
BadMethodCallException

when another field as _mh will be gotten

throws
RuntimeException

when curl can not initialize a multi handle

Return values
resource|CurlMultiHandle

execute()

Runs until all outstanding connections have completed.

public execute() : void
Return values
void

tick()

Ticks the curl event loop.

public tick() : void
Return values
void

addRequest()

private addRequest(array<string|int, mixed> $entry) : void
Parameters
$entry : array<string|int, mixed>
Return values
void

cancel()

Cancels a handle from sending and removes references to it.

private cancel(int $id) : bool
Parameters
$id : int

Handle ID to cancel and remove.

Return values
bool

True on success, false on failure.

processMessages()

private processMessages() : void
Return values
void

Search results