neu/curl

A PHP library to easily run multiple cUrl requests in parallel.

v0.2.0 2021-10-13 13:55 UTC

This package is auto-updated.

Last update: 2024-04-13 19:43:17 UTC


README

neu/curl is a helper library for PHP's cURL extension. It provides object-oriented wrappers for native imperative code and an easy API to queue cURL calls, execute them in parallel, and get back the result as an array.

Usage

Wrappers

The classes Neu\Curl\Curl and Neu\Curl\MultiCurl are wrappers for the curl_* and curl_multi_* functions respectively. The method names follow the names of the native functions, but make use of camelCase instead of snake_case.

Neu\Curl\CurlPool

Neu\Curl\CurlPool allows you to easily queue cURL calls. Calls are collected either through the queue(string $url, string $method = 'GET', $body = '') method or by adding a manually configured Neu\Curl\Curl instance via addInstance(Curl $curl).

In order to get execute the requests and get their results, the exec() method is called. Upon resolution of all requests, an array is returned, containing all responses, ordered by their respective request.

License

neu/curl is available under the terms of the GNU Lesser General Public License in version 3.0 or later.