Download the PHP package arch/multicurl without Composer
On this page you can find all versions of the php package arch/multicurl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arch/multicurl
More information about arch/multicurl
Files in arch/multicurl
Package multicurl
Short Description Multi Curl request with batch and parallel request
License MIT License
Informations about the package multicurl
Multi Curl
Multi Curl with batch and parallel request. As the name suggest, you can make a batch request or parallel request at once.
Batch Request
Will split array data provided, and request part by part to minimize workload during request instead of requesting at once. Defining how much the number of data per request is at your own choices. The batch request simply divided array of url(s) part by part and doing the request one by one until finish. While waiting for next queue of request, you can provide callback for each batch to execute.
Paraller Request
Passed in the whole set of array data and will request all at once.
Installation
Library can be installed using composer, just require it :
composer require arch/multicurl
Usage Example
1) Inside file just include Arch\MultiCurl\MultiCurl
at the top of page:
2) Instantiate library and call the available method :
Options
1) new MultiCurl( $urls, $perRequest )
accept two parameter for initial configuration.
- $urls = ( Required ). Array of url(s)/endpoint(s)
- $perRequest = ( Optional ). Indicate the number of data(length) per request and default is 5. This config is for batch request only as the default option for curl operation is a batch instead of requesting the whole set of url(s). You can change this option, see below section.
2) Change default operation for curl either to batch request or all at once by calling setBatchOperation()
method, default is true
for batch request operation :
3) Providing callback in execute( fn(x) )
for batch request whenever its finish executing the request for each batch. As example, we have 3 batch requests, and the callback provided will run 3 times for each batch with the result it received. This callback have 1 arguments for result set
receive from the endpoints. This callback is optional.
- $data = Results received from the endpoints