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

Properties

$_mh  : resource|CurlMultiHandle
$active  : int
$delays  : array<int, float>
$factory  : CurlFactoryInterface
$handles  : array<string|int, mixed>
$options  : array<string|int, mixed>
$selectTimeout  : int

Methods

__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
tickInQueue()  : void
Runs \curl_multi_exec() inside the event loop, to prevent busy looping
timeToNext()  : int

Properties

$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> = []

__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

addRequest()

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

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.

tickInQueue()

Runs \curl_multi_exec() inside the event loop, to prevent busy looping

private tickInQueue() : void

        
On this page

Search results