PHP Classes

PHP Multi Curl Async: Send multiple parallel HTTP requests using Curl

Recommend this page to a friend!

  Author Author  
Picture of Smoren  Freelight
Name: Smoren Freelight <contact>
Classes: 20 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 9x


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This package can send multiple parallel HTTP requests using Curl.

It provides a class to queue multiple HTTP requests that it will send asynchronously using the PHP Curl extension.

The package provides another class to send the HTTP requests and collect the responses until all parallel requests are processed.

Details

multicurl

Multi curl wrapper for making parallel HTTP requests

Packagist PHP Version Support Scrutinizer Code Quality Coverage Status Build and test License: MIT

How to install to your project

composer require smoren/multicurl

Unit testing

composer install
composer test-init
composer test

Usage

use Smoren\MultiCurl\MultiCurl;

$mc = new MultiCurl(10, [
    CURLOPT_POST => true,
    CURLOPT_FOLLOWLOCATION => 1,
], [
    'Content-Type' => 'application/json',
]);

$mc->addRequest(1, 'https://httpbin.org/anything', ['some' => 'data']);
$mc->addRequest(2, 'https://httpbin.org/anything', ['some' => 'another data']);

$result = $mc->makeRequests();
print_r($result);

/*
Array
(
    [1] => Array
        (
            [code] => 200
            [headers] => Array
                (
                    [Date] => Sat, 14 May 2022 08:21:35 GMT
                    [Content-Type] => application/json
                    [Content-Length] => 459
                    [Connection] => keep-alive
                    [Server] => gunicorn/19.9.0
                    [Access-Control-Allow-Origin] => *
                    [Access-Control-Allow-Credentials] => true
                )

            [body] => Array
                (
                    [args] => Array
                        (
                        )

                    [data] => {"some":"data"}
                    [files] => Array
                        (
                        )

                    [form] => Array
                        (
                        )

                    [headers] => Array
                        (
                            [Accept] => 
                            [Accept-Encoding] => deflate, gzip
                            [Content-Length] => 15
                            [Content-Type] => application/json
                            [Host] => httpbin.org
                            [X-Amzn-Trace-Id] => Root=1-627f668f-2c004f4e5817d2b508e0cd6c
                        )

                    [json] => Array
                        (
                            [some] => data
                        )

                    [method] => POST
                    [origin] => 46.22.56.202
                    [url] => https://httpbin.org/anything
                )

        )

    [2] => Array
        (
            [code] => 200
            [headers] => Array
                (
                    [Date] => Sat, 14 May 2022 08:21:36 GMT
                    [Content-Type] => application/json
                    [Content-Length] => 475
                    [Connection] => keep-alive
                    [Server] => gunicorn/19.9.0
                    [Access-Control-Allow-Origin] => *
                    [Access-Control-Allow-Credentials] => true
                )

            [body] => Array
                (
                    [args] => Array
                        (
                        )

                    [data] => {"some":"another data"}
                    [files] => Array
                        (
                        )

                    [form] => Array
                        (
                        )

                    [headers] => Array
                        (
                            [Accept] => 
                            [Accept-Encoding] => deflate, gzip
                            [Content-Length] => 23
                            [Content-Type] => application/json
                            [Host] => httpbin.org
                            [X-Amzn-Trace-Id] => Root=1-627f668f-67767ca73cdb2bf313afa566
                        )

                    [json] => Array
                        (
                            [some] => another data
                        )

                    [method] => POST
                    [origin] => 46.22.56.202
                    [url] => https://httpbin.org/anything
                )

        )

)
 */

  Classes of Smoren Freelight  >  PHP Multi Curl Async  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Multi Curl Async
Base name: multicurl-php
Description: Send multiple parallel HTTP requests using Curl
Version: 1.0.0
PHP version: 5
License: MIT/X Consortium License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image HTTP HTTP protocol clients, headers and cookies View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (2 files)
Files folder imagetests (3 files, 2 directories)
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test_master.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file MultiCurl.php Class Class source
  Plain text file MultiCurlRunner.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageunit (1 file)
Files folder image_support (1 file)
  Accessible without login Plain text file coding_standard.xml Data Auxiliary data
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file _bootstrap.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  unit  
File Role Description
  Plain text file MultiCurlTest.php Class Class source

  Files folder image Files  /  tests  /  _support  
File Role Description
  Plain text file UnitTester.php Class Class source

Install with Composer Install with Composer - Download Download all files: multicurl-php.tar.gz multicurl-php.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (2 files)
Files folder imagetests (3 files, 2 directories)
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test_master.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file MultiCurl.php Class Class source
  Plain text file MultiCurlRunner.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageunit (1 file)
Files folder image_support (1 file)
  Accessible without login Plain text file coding_standard.xml Data Auxiliary data
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file _bootstrap.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  unit  
File Role Description
  Plain text file MultiCurlTest.php Class Class source

  Files folder image Files  /  tests  /  _support  
File Role Description
  Plain text file UnitTester.php Class Class source

Install with Composer Install with Composer - Download Download all files: multicurl-php.tar.gz multicurl-php.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.