PHP Classes

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-04-21 (11 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 68 This week: 1All time: 10,286 This week: 560Up
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: 36 packages by
Country: Russian Federation Russian Federation
Age: 34
All time rank: 290379 in Russian Federation Russian Federation
Week rank: 106 Up7 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 15x

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  
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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:68
This week:1
All time:10,286
This week:560Up