Zebra_cURL, a high performance PHP cURL library

Get the latest updates on this PHP library via RSS

You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “Zebra_cURL, a high performance PHP cURL library”.

52 responses to “Zebra_cURL, a high performance PHP cURL library”

Follow the comments via RSS
  • Nate, 2014-06-05, 00:02

    Hi, I followed the sample for doing a post from the documentation and I keep getting:

    Fatal error: Callback function "Array" does not exist! in /homepages/1/d146197026/htdocs/HDPhim/Zebra_cURL.php on line 1509

    Any idea why?

  • Ron, 2014-07-22, 16:34

    Great work on the script.
    Could you give a quick example of how to authenticate to a webiste, and once logged in make several get requests.

    I tried using the http_authentication function but it didn’t seem to. I must be missing something.


  • Tony, 2014-10-13, 02:59

    Dumb question: I would like to know how to simplexml_load_file the cached file.

    • Tony, 2014-10-13, 08:48

      Ok, I figured out the issue with simple_xml_load_file.

      $var = unserialize (gzuncompress(file_get_contents(ZEBRACURL . 'cache/' . $Md5name)));
      $NewVar = simplexml_load_string(html_entity_decode ($var->body));

      However, it would be nice if cached files were stored in such a manner as to limit the number of files per directory. Right now, all filenames use their md5 value and are placed in one common folder .. which is great until there are like 100,000+ files in one folder. I imagine performance would suffer.

      eAccelerator has a nice and fast directory / file placement structure. You create a directory based on the first character of the file name, create a sub-directory based on the second character of the filename, and so forth. After creating directories 5 or 6 levels deep, the file would then be placed.

    • Tony, 2015-07-18, 04:35

      Actually, what happens when thousands and thousands of files are in one directory is that you hit the iNode limit, the server freaks out, and you can’t login to cPanel.

      Ummmm, so. Any chance of editing your script to create directories similar to eAccelerator (which doesn’t seem to suffer the iNode problem due to its directory structure ….)

  • Tony, 2014-10-13, 08:50
    filename => 1dd51d2133952cea5e8202b4360aa39d
    directory => cache/1/d/d/5/1/1dd51d2133952cea5e8202b4360aa39d
  • noname, 2014-12-23, 12:07

    Does not work for me. Even when I only allowed 2 threads at a time, it stops working after between 700 and 1400 downloads (small files) and I have to restart the process. The error I’m getting is CURLE_COULDNT_CONNECT

    • Stefan Gabos, 2014-12-26, 14:52

      The server where you’re downloading from starts rejecting your requests because you’re asking for too much too quickly

  • Branislav Kirilov, 2015-01-09, 17:15

    Great class with 2 major drawbacks.
    1. Real pain to add more arguments to callback function. I’ve managed to do it, but not without editing the class. If there is a better way please advise. What I had to do is this
    $this->zcurl->post($urls_array, $options_array, array($this, 'curl_callbacks'),array('order_id' => $oip['order_id']));
    2. The bigger issue is if i want to add different post values.
    Calling $curl->post with array of urls can’t be called with array of values (example is above) which kind of defeats the purpose of the multi curl. If I have to make each query on new line, then there is nothing multi in my queries.

    • Stefan Gabos, 2015-01-12, 12:32

      1. I disagree: it works as per your example by default; any other arguments to the post() method will be passed to the callback function
      2. I agree and I am working on that


  • thinkvitamin, 2015-01-13, 23:53

    I’m interested in caching with cURL more than anything else. I found this script on Stack Overflow which unmasks redirect links:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $a = curl_exec($ch);

    $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

    echo $url;

    Would there be any special way of re-writing that with Zebra cURL?

    • Stefan Gabos, 2015-01-16, 13:25

      Zebra_cURL already shows you all the redirects

  • Williem, 2015-02-11, 00:04

    hi, thanks for this great class, i want to know if there is any way to make soap requests (soap client) with it, i am trying to write a php script which will send asynchronous SOAP request to a soap server.


  • frederictb, 2015-03-21, 06:57

    It’s seems that we have not the netx line into
    public function ftp_download($urls, $path, $username = ”, $password = ”, $callback = ”)

    $arguments = func_get_args();
    With the FTP sample this make a warning

  • frederictb, 2015-03-25, 09:56

    I use the zebra_curl and i don’t knwo how can i handle the callback.
    I want to call some method like post, get, etc…. Typically my source is
    if (curl->post(..) === true ) {
    if ( curl->get() === true ) {
    // Do something

    What is the best way to manage the return callback and to handle the operation in the correct appraoch ?

    The one way that i find is to hava for each callback a specific variable. Before calling the zebra method to do
    mycallbakc_sem = NULL

    In the callback i update this semaphore with true or false.

    Juste after my curl post i have a while like
    while ( mycallback === NULL ) {

    If there are another better possibility let me knwow.

    Do you ad the http return code into the next zebra version ?

    • Stefan Gabos, 2015-03-25, 14:25

      it doesn’t work like that with Zebra_cURL
      look at the examples here.
      also, the http code is available in the returned object

  • Johnn, 2015-04-24, 17:20

    Neat plugins and libraries on this site. This cURL libary seems to come in handy at large, in my case I am looking though for a library which supports retry of failed requests though, it doesn’t seem to be the case here. Or maybe this is not possible anyway while performing multiple requests.

  • Isaac, 2015-05-16, 14:46

    I was just wondering before I switched to this class…I was looking at the documentation for the cURL class and found that under cURL Post, cURL File was unset. Does this mean its disabled or something?

    I noticed under documentation that the POST for a file was still done as a ‘@’ method, however the recent documented recommendation was to use cURLFILE to process it instead. Would using cURL file work? And if so how do we combine it with your class?

  • Isaac, 2015-05-16, 17:39

    Sorry to make this a mess, but is there anyway to place the get page into a variable? IE. I have used the Zebra Curl to obtain the html code of google.com and i wish to use preg_match on it. Is there anyway this is possible?

  • Neil, 2015-06-03, 01:55


    i have tried using the sample on using proxy ip/port from the following url, but it doesn’t work, i of course changed the ip/port to one which is working and also changed the url to google.


  • Lamoed, 2015-08-31, 09:03

    Need help please.
    How to stop queue if one result return correct information?


Leave a Reply

Your email address will not be published
You can use <strong>, <em>, <a>, <img>, <code>
Characters are not case-sensitive