Download the PHP package chuyskywalker/rolling-curl without Composer
On this page you can find all versions of the php package chuyskywalker/rolling-curl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chuyskywalker/rolling-curl
More information about chuyskywalker/rolling-curl
Files in chuyskywalker/rolling-curl
Package rolling-curl
Short Description Rolling-Curl: A non-blocking, non-dos multi-curl library for PHP
License Apache-2.0
Homepage https://github.com/chuyskywalker/rolling-curl
Informations about the package rolling-curl
RollingCurl
A cURL library to fetch a large number of resources while maintaining a consistent number of simultaneous connections
Authors:
- Jeff Minard (jrm.cc)
- Josh Fraser (joshfraser.com)
- Alexander Makarov (rmcreative.ru)
Overview
RollingCurl is a more efficient implementation of curl_multi().
curl_multi is a great way to process multiple HTTP requests in parallel in PHP but suffers from a few faults:
- The documentation for curl_multi is very obtuse and, as such, is easy to incorrectly or poorly implement
- Most curl_multi examples queue up all requests and execute them all at once
The second point is the most important one for two reasons:
- If you have to wait on every single request to complete, your program is "blocked" by the longest running request.
- More importantly, when you run a large number of cURL requests simultaneously you are, essentially, running a DOS attack. If you have to fetch hundreds or even thousands of URLs you're very likely to be blocked by automatic DOS systems. At best, you're not being a very respectful citizen of the internet.
RollingCurl deals with both issues by maintaining a maximum number of simultaneous requests and "rolling" new requests into the queue as existing requests complete. When requests complete, and while other requests are still running, RollingCurl can run an anonymous function to process the fetched result. (You have the option to skip the function and instead process all requests once they are done, should you prefer.)
Installation (via composer)
Get composer and add this in your requires section of the composer.json:
and then
Usage
Basic Example
Fetch A Very Large Number Of Pages
Let's scrape google for the first 500 links & titles for "curl"
Setting custom curl options
For every request
For a single request:
More examples can be found in the examples/ directory.
TODO:
- PHPUnit test
- Ensure PSR spec compatibility
- Fix TODOs
- Better validation on setters
Feel free to fork and pull request to help out with the above. :D
Similar Projects
All versions of rolling-curl with dependencies
ext-curl Version *
lib-curl Version *