PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Elminson De Oleo   PHP Multi Curl Library   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Read me
Class: PHP Multi Curl Library
Process multiple HTTP requests at the same time
Author: By
Last change:
Date: 4 years ago
Size: 1,922 bytes
 

Contents

Class file image Download

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