Documentation

CurlMulti extends AbstractHasDispatcher
in package
implements CurlMultiInterface

Send {@see RequestInterface} objects in parallel using curl_multi

Table of Contents

Interfaces

CurlMultiInterface
Interface for sending a pool of {@see RequestInterface} objects in parallel

Properties

$eventDispatcher  : EventDispatcherInterface
$exceptions  : array<string|int, mixed>
$handles  : SplObjectStorage
$multiErrors  : array<string|int, mixed>
$multiHandle  : resource
$requests  : array<string|int, mixed>
$resourceHash  : array<string|int, mixed>
$selectTimeout  : float
$successful  : array<string|int, mixed>

Methods

__construct()  : mixed
__destruct()  : mixed
add()  : CurlMultiInterface
Add a request to the pool.
addSubscriber()  : self
Add an event subscriber to the dispatcher
all()  : array<string|int, mixed>
Get an array of attached {@see RequestInterface} objects
count()  : mixed
dispatch()  : Event
Helper to dispatch Guzzle events and set the event name on the event
getAllEvents()  : array<string|int, mixed>
Get a list of all of the events emitted from the class
getEventDispatcher()  : EventDispatcherInterface
Get the EventDispatcher of the request
remove()  : bool
Remove a request from the pool.
reset()  : mixed
Reset the state and remove any attached RequestInterface objects
send()  : mixed
Send a pool of {@see RequestInterface} requests.
setEventDispatcher()  : self
Set the EventDispatcher of the request
beforeSend()  : mixed
Prepare for sending
createCurlHandle()  : CurlHandle
Create a curl handle for a request
perform()  : mixed
Get the data from the multi handle
processResponse()  : mixed
Check for errors and fix headers of a request based on a curl response
removeErroredRequest()  : mixed
Remove a request that encountered an exception
removeHandle()  : mixed
Remove a curl handle from the curl multi object
throwMultiException()  : mixed
Build and throw a MultiTransferException
addHandle()  : mixed
checkCurlResult()  : mixed
Throw an exception for a cURL multi response if needed
executeHandles()  : mixed
Execute and select curl handles
isCurlException()  : CurlException|bool
Check if a cURL transfer resulted in what should be an exception
processMessages()  : mixed
Process any received curl multi messages
validateResponseWasSet()  : mixed

Properties

$exceptions

protected array<string|int, mixed> $exceptions = array()

Queued exceptions

$handles

protected SplObjectStorage $handles

RequestInterface to CurlHandle hash

$multiErrors

protected array<string|int, mixed> $multiErrors = array(CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'), CURLM_BAD_EASY_HANDLE => array('CURLM_BAD_EASY_HANDLE', "An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle."), CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'), CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'))

cURL multi error values and codes

$multiHandle

protected resource $multiHandle

cURL multi handle.

$resourceHash

protected array<string|int, mixed> $resourceHash

Hash mapping curl handle resource IDs to request objects

$selectTimeout

protected float $selectTimeout

$successful

protected array<string|int, mixed> $successful = array()

Requests that succeeded

Methods

__construct()

public __construct([mixed $selectTimeout = 1.0 ]) : mixed
Parameters
$selectTimeout : mixed = 1.0

all()

Get an array of attached {@see RequestInterface} objects

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

count()

public count() : mixed
Attributes
#[ReturnTypeWillChange]

dispatch()

Helper to dispatch Guzzle events and set the event name on the event

public dispatch(mixed $eventName[, array<string|int, mixed> $context = array() ]) : Event
Parameters
$eventName : mixed

Name of the event to dispatch

$context : array<string|int, mixed> = array()

Context of the event

Return values
Event

Returns the created event object

getAllEvents()

Get a list of all of the events emitted from the class

public static getAllEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

remove()

Remove a request from the pool.

public remove(RequestInterface $request) : bool
Parameters
$request : RequestInterface

Request to remove

Return values
bool

Returns true on success or false on failure

reset()

Reset the state and remove any attached RequestInterface objects

public reset([mixed $hard = false ]) : mixed
Parameters
$hard : mixed = false

Set to true to close and reopen any open multi handles

send()

Send a pool of {@see RequestInterface} requests.

public send() : mixed

perform()

Get the data from the multi handle

protected perform() : mixed

processResponse()

Check for errors and fix headers of a request based on a curl response

protected processResponse(RequestInterface $request, CurlHandle $handle, array<string|int, mixed> $curl) : mixed
Parameters
$request : RequestInterface

Request to process

$handle : CurlHandle

Curl handle object

$curl : array<string|int, mixed>

Array returned from curl_multi_info_read

Tags
throws
CurlException

on Curl error

removeErroredRequest()

Remove a request that encountered an exception

protected removeErroredRequest(RequestInterface $request[, Exception $e = null ]) : mixed
Parameters
$request : RequestInterface

Request to remove

$e : Exception = null

Exception encountered

throwMultiException()

Build and throw a MultiTransferException

protected throwMultiException(array<string|int, mixed> $exceptions, array<string|int, mixed> $successful) : mixed
Parameters
$exceptions : array<string|int, mixed>

Exceptions encountered

$successful : array<string|int, mixed>

Successful requests

Tags
throws
MultiTransferException

checkCurlResult()

Throw an exception for a cURL multi response if needed

private checkCurlResult(int $code) : mixed
Parameters
$code : int

Curl response code

Tags
throws
CurlException

executeHandles()

Execute and select curl handles

private executeHandles() : mixed

processMessages()

Process any received curl multi messages

private processMessages() : mixed

        
On this page

Search results