Download the PHP package bluepsyduck/multicurl without Composer
On this page you can find all versions of the php package bluepsyduck/multicurl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bluepsyduck/multicurl
More information about bluepsyduck/multicurl
Files in bluepsyduck/multicurl
Package multicurl
Short Description Simple library helping with requesting multiple resources at once using multi cUrl.
License GPL-2.0
Homepage https://github.com/BluePsyduck/MultiCurl
Informations about the package multicurl
BluePsyduck's MultiCurl Library
This library helps with creating and executing multiple requests simultaneously using the Multi-cURL functions of PHP.
Requirements
- PHP 7.0 or newer
- PHP cURL extension
Usage
The main class of the library is the MultiCurlManager
, to which you can add as many requests as you like and which
will execute them. For each request to be started, create an instance of the Entity\Request
class and set its
properties as required, and add it to the manager using $manager->addRequest($request)
. Added requests will
immediately be executed, without blocking the script execution.
To wait for a certain request to finish, call $manager->waitForSingleRequest($request)
. To wait for all requests to
finish, call $manager->waitForAllRequests()
. These methods will block script execution until the desired requests are
finished.
Once a request is finished, use $request->getResponse()
to get the information of the response. You may want to check
$response->getErrorCode()
and $response->getErrorMessage()
to get any information in case the request has failed.
The requests offer two callbacks:
- onInitialize: This callback is triggered once the underlying cURL request has been initialized. Use this callback to further manipulate the cURL. After this callback, the cURL request gets executed.
- onComplete: This callback is triggered once the cURL request finished and the response has been parsed into the entity.
Examples
Here is a basic example demonstrating the use of the MultiCurlManager
:
Here is another example demonstrating limiting the number of parallel requests:
All versions of multicurl with dependencies
ext-curl Version *