PHP Classes

MultiCurl: Retrieve multiple pages simultaneously

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 64%Total: 1,766 All time: 2,220 This week: 206Up
Version License PHP version Categories
multicurl 1.07GNU Lesser Genera...5.0Networking, HTTP, PHP 5
Description 

Author

This class can be used to retrieve multiple pages simultaneously from remote Web servers.

It uses PHP Curl extension to establish one or more HTTP requests that may be executed in parallel.

The class supports:

- Only a limited number of requests are executed in parallel, so exceeding requests are delayed until prior requests are finished
- Restrict the size of retrieved data to a given limit
- Set common CURL options for all requests
- Set separate CURL options for different requests when necessary
- Use callback events for response result processing.

Innovation Award
PHP Programming Innovation award nominee
September 2007
Number 6


Prize: One copy of the Zend Studio
PHP can access Web resources either using HTTP connections established by the fsockopen function or the Curl library functions.

The Curl library provides support to establish multiple HTTP connections in parallel, thus retrieving resources from several Web servers at the same time.

This class takes advantage of this feature of the Curl library to provide a more elegant interface to access data from multiple Web sites in less time.

Manuel Lemos
Picture of V
Name: V <contact>
Classes: 3 packages by
Country: The Netherlands The Netherlands
Age: 49
All time rank: 85222 in The Netherlands The Netherlands
Week rank: 360 Up10 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
include_once '../MultiCurl.class.php';

class
MyMultiCurl extends MultiCurl {
    protected function
onLoad($url, $content, $info) {
        print
"[$url] $content ";
       
print_r($info);
    }
}

try {
   
$mc = new MyMultiCurl();
   
$mc->setMaxSessions(2); // limit 2 parallel sessions (by default 10)
   
$mc->setMaxSize(10240); // limit 10 Kb per session (by default 10 Mb)
   
$mc->addUrl('http://google.com');
   
$mc->addUrl('http://yahoo.com');
   
$mc->addUrl('http://altavista.com');
   
$mc->wait();
} catch (
Exception $e) {
    die(
$e->getMessage());
}


  Files folder image Files  
File Role Description
Accessible without login Plain text file MultiCurl.class.php Class MultiCurl class
Accessible without login Plain text file example.php Example Example
Accessible without login Plain text file README Doc. README
Accessible without login Plain text file LICENSE Lic. LICENSE

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,766
This week:0
All time:2,220
This week:206Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:64%StarStarStarStar
Rank:727