PHP Classes

MultiCurl: Retrieve multiple pages simultaneously

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2010-11-07 (6 years ago) RSS 2.0 feedNot enough user ratingsTotal: 1,719 All time: 2,222 This week: 771Up
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
Name: Vadym Timofeyev <contact>
Classes: 3 packages by
Country: The Netherlands The Netherlands
Age: 42
All time rank: 84124 in The Netherlands The Netherlands
Week rank: 997 Down28 in The Netherlands The Netherlands Down
Innovation award
Innovation award
Nominee: 1x

README (MultiCurl class)

NAME: MultiCurl class


AUTHOR: Vadym Timofeyev <>


    MultiCurl class provides a convenient way to execute parallel HTTP(S)
    requests via PHP MULTI CURL extension with additional restrictions.
    For example: start 100 downloads with 2 parallel sessions, and get only
    first 100 Kb per session.

    Supported features:

      - Set query for CURL multi sessions. The main idea you can use only
        limited number of parallel requests. If you add next request and
        the query is fully filled the script waits while one or some previous
        CURL multi sessions will be completed.

      - Set maximal size limit for downloaded content. Please note: it is
        possible to download rather more bytes than the limit because download
        operation uses internal buffer.
      - Set common CURL options for all requests.
      - Set separate CURL options for different requests if it is necessary.


    include_once 'MultiCurl.class.php';

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

    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)
    } catch (Exception $e) {


    Copyright (c) 2007 Vadym Timofeyev. All rights reserved.
    This software is released under the GNU Lesser General Public License.
    Please read the disclaimer at the top of the MultiCurl.class.php file.
  Files folder image Files  
File Role Description
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 ChangeLog Data ChangeLog
Accessible without login Plain text file LICENSE Lic. LICENSE

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:2,222
This week:771Up