selfworks/parallelcurl

A PHP class providing an easy interface for running multiple concurrent CURL requests.

v1.5 2018-11-02 08:07 UTC

This package is auto-updated.

Last update: 2024-10-29 05:22:47 UTC


README

GitHub release GitHub stars Github All Releases GitHub issues GitHub license

A PHP class providing an easy interface for running multiple concurrent CURL requests

<?php
$maxRequests = 2;
$curlOptions = array(
    CURLOPT_SSL_VERIFYPEER => FALSE,
    CURLOPT_SSL_VERIFYHOST => FALSE,
    CURLOPT_FOLLOWLOCATION => 1,
    CURLOPT_VERBOSE => 0,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_ENCODING => 'gzip, deflate',
);

$parallelCurl = new \SelfWorks\PrallelCURL\ParallelCurlClass($maxRequests, $curlOptions);
$parallelCurl->startRequest("https://google.com", 
    array(
        'request_id'=>1
    ));

$parallelCurl->startRequest("https://youtube.com", array(
        'request_id'=>2
));
$requestedContent = $parallelCurl->finishAllRequests();

?>