PHP Classes
elePHPant
Icontem

PHP Multi Curl Library: Process multiple HTTP requests at the same time

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-04-16 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: 56 This week: 56All time: 9,700 This week: 6Up
Version License PHP version Categories
multiproccessingcurl 1.0.0GNU General Publi...5HTTP, PHP 5
Description Author

This class can process multiple HTTP requests at the same time.

It can take an array with the parameters of multiple HTTP requests to be send with the PHP Curl extension, like for instance the URL, the request payload data and the request method.

The class can queue all the requests at the same time and return the response for each request as soon and the respective remote HTTP server finishes sending the respective response.

  Performance   Level  
Name: Elminson De Oleo <contact>
Classes: 3 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 2x

 

Details

MultiProccessingCurlRequests

composer require elminson/multiproccessingcurlrequests

Proccessing Multiple cURL requests in PHP faster

<?php
namespace Elminson\MultiProccessingCurlRequests;

require __DIR__ . '/vendor/autoload.php';

        $data = [
          ['url' => 'https://jsonplaceholder.typicode.com/todos/1'],
          ['url' => 'https://jsonplaceholder.typicode.com/users']
        ];
        $call = new MultiProccessingCurlRequests();
        $call->setIsJson(true);
        $r = $call->multiRequest($data);
        var_dump($r);

Send Request in json format

<?php
namespace Elminson\MultiProccessingCurlRequests;

require __DIR__ . '/vendor/autoload.php';

    	$payloadArray = array("name" => "John", "phone" => "555-555-5555");
        $data = [
          ['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'payload' => json_encode($payloadArray)],
          ['url' => 'https://jsonplaceholder.typicode.com/users', 'payload' => json_encode($payloadArray)]
        ];
        $call = new MultiProccessingCurlRequests();
        $call->setIsJson(true);
        $r = $call->multiRequest($data);
        var_dump($r);

Send Request in json and post format

<?php

namespace Elminson\MultiProccessingCurlRequests;

require __DIR__ . '/vendor/autoload.php';
        $payloadArray = array("name" => "John", "phone" => "555-555-5555");
		$data = [
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'post' => $payloadArray],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'post' => $payloadArray]
		];
		$call = new MultiProccessingCurlRequests();
		$call->setIsJson(true);
		$r = $call->multiRequest($data);
		var_dump($r);
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me
Accessible without login Plain text file tests.php Example Example script

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

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:56
This week:56
All time:9,700
This week:6Up