xpaw / crimp
一个简单的多curl实现,针对高并发进行了优化。
2.0.0
2023-02-28 19:32 UTC
Requires
- php: >=8.0
- ext-curl: *
README
一个简单的多curl实现,针对高并发进行了优化。
这实际上是一个骨架实现。重试、HTTP代码检查以及其他功能由用户负责。
用法
$Crimp = new Crimp( function( CurlHandle $Handle, string $Data, $Request ) : void { // $Handle is the cURL handle // $Data is the content of a cURL handle // $Request is whatever was queued } ); // How many concurrent threads to use $Crimp->Threads = 10; // Set any curl option that are needed $Crimp->CurlOptions[ CURLOPT_FOLLOWLOCATION ] = 1; // Queue urls $Crimp->Add( 'https://example.com/?v=1' ); $Crimp->Add( 'https://example.com/?v=2' ); // Queue an array, it must contain a `Url` key $Crimp->Add( [ 'Url' => 'https://example.com/?v=3' ] ); // Queue an object, it must contain a `Url` property class RequestUrl { public string $Url; } $request = new RequestUrl(); $request->Url = 'https://example.com/?v=4'; $Crimp->Add( $request ); // Execute the requests $Crimp->Go();
CURLOPT_RETURNTRANSFER
默认启用。更多信息请参阅示例文件夹。
如果您需要一个功能齐全的多curl实现,请查看Zebra_cURL或Guzzle。