Download the PHP package maurice2k/multicurl without Composer
On this page you can find all versions of the php package maurice2k/multicurl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maurice2k/multicurl
More information about maurice2k/multicurl
Files in maurice2k/multicurl
Package multicurl
Short Description Object based asynchronous multi-curl wrapper
License MIT
Informations about the package multicurl
maurice2k/multicurl
Maurice\Multicurl
provides an easy object-oriented interface for PHP's curl_multi_*
functions.
It's not only a wrapper but also provides the event loop, takes care that a given number of concurrent connections is not exceeded and also handles timeouts (connection and total timeouts).
Maurice\Multicurl
basically consists of a Manager
that orchestrates multiple Channel
-based instances. In theory a channel can be of any connection type that cURL supports while practically the current version of Maurice\Multicurl
only implements an HttpChannel
on top of Channel
.
Installation
Install with composer:
Compatibility
Maurice\Multicurl
requires PHP 7.4 (or better) with the curl extension enabled.
Usage
Basic example
Outputs something like this:
Adding new channels on the fly
In this example we're implementing a super simple web crawler that starts at Wikipedia's "Web Crawler" page and extracts at most five new pages per crawled page until 20 pages have been put into the manager (successfully crawled or not).
A cleaner way would have been to create a HttpCrawlChannel
(extending HttpChannel
) that directly implements and overwrites HttpChannel's onReady
method (as well as onTimeout
and onError
).
Outputs something like this:
All versions of multicurl with dependencies
ext-curl Version ^7.4 || ~8.0
ext-json Version ^7.4 || ~8.0