PHP Classes

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

Recommend this page to a friend!
     
  Info   Example   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: 123 All time: 9,471 This week: 673Up
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.

Picture of Elminson De Oleo
  Performance   Level  
Innovation award
Innovation award
Nominee: 2x

 

Example

<?php

namespace Elminson\MultiProccessingCurlRequests;

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

$data = [
    [
'url' => 'https://www.google.com']
];
$call = new MultiProccessingCurlRequests();
$call->setIsPost(false);
$r = $call->multiRequest($data);
$result = strip_tags($r[0]);
print_r($result);


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

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:123
This week:0
All time:9,471
This week:673Up