PHP Classes

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

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 70 This week: 1All time: 10,286 This week: 36Up
Version License PHP version Categories
multicurl-php 1.0.0MIT/X Consortium ...5HTTP, PHP 5
Description 

Author

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.

Picture of Smoren  Freelight
  Performance   Level  
Name: Smoren Freelight <contact>
Classes: 38 packages by
Country: Russian Federation Russian Federation
Age: 35
All time rank: 280778 in Russian Federation Russian Federation
Week rank: 11 Up1 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 16x

Documentation

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
                )

        )

)
 */

  Files folder image Files (12)  
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 (12)  /  .github  
File Role Description
Files folder imageworkflows (1 file)

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

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

  Files folder image Files (12)  /  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 (12)  /  tests  /  unit  
File Role Description
  Plain text file MultiCurlTest.php Class Class source

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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:70
This week:1
All time:10,286
This week:36Up