litek / fetcher
此包最新版本(dev-master)没有可用的许可证信息。
dev-master
2012-09-24 21:41 UTC
This package is not auto-updated.
Last update: 2024-09-28 12:43:17 UTC
README
cURL 的并行获取 URL 封装器
$google = new Fetcher\Client; $google->queue('http://google.com/', function($response) { // handle response }); $bing = new Fetcher\Client; $bing->queue('http://bing.com/', function($response, $bing, $master) { // you can also queue a new url for fetching when reacting on a response $bing->queue('http://url', function($response) { // handle response }); // or even attach another client for parallel retrieval $yahoo = $master->createClient(); $yahoo->queue('http://yahoo.com/', function($response) { // handle this response }); }); // run in parallel $master = new Fetcher\Parallel; $master->run([$google, $bing]); // will be done after the slowest request chain, instead of the sum of requests echo "Done.";
在同一客户端上排队的多个请求将按顺序运行。
也可用作单个请求的 cURL 封装器。
$example = new Fetcher\Client; $example->queue('http://example.org/', function($response) { // handle response })->run();