Skip to content

A simple PHP class for making parallel requests with curl using callbacks and retries.

Notifications You must be signed in to change notification settings

sorbing/curl-multi-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

CurlMulti

A simple PHP class for making parallel requests with curl using callbacks and retries.

The code consists of a CurlMultiRequest class that acts as a wrapper for the cURL options. The Requests handles the action when it is finished by the manager. It also decides when to retry.

The CurlMultiManager is capeable of starting multiple requests and limit the number of parallel requests. It calls the CurlMultiRequest::process() which calls the callback.

Example Code

Minimal example code using 'var_dump' as callback.

<?php
require_once __DIR__.'/CurlMulti.php';

// Config
$max_parallel_requests = 2;
$tries_max = 3;
$urls = array(
  'https://github.com/',
  'http://soundcloud.com/',
  'http://juliusbeckmann.de/',
);

$manager = new CurlMultiManager($max_parallel_requests);
foreach($urls as $url) {
  $request = $manager->newRequest($url);
  $request->setCallback('var_dump');
  $request->setTriesMax($tries_max);
  $manager->startRequest($request);
}
$manager->finishAllRequests();
?>

About

A simple PHP class for making parallel requests with curl using callbacks and retries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published