tereta/curl
Composer 安装命令:
composer require tereta/curl
包简介
Tereta/Curl is a facade over cURL. For everyday tasks there is a simple facade with `get()` and `post()` methods, and for several requests at once — parallel execution powered by `curl_multi`.
README 文档
README
🌐 English | Русский | Українська
Contents
Introduction
Tereta/Curl is a facade over cURL. For everyday tasks there is a simple facade with get() and post() methods, and for several requests at once — parallel execution powered by curl_multi.
Requirements
- PHP 8.2 or newer.
- The
ext-curlextension.
Installation
composer require tereta/curl
Repository: https://gitlab.com/tereta/library/curl
Usage
The entry point is the Tereta\Curl\Client facade.
Available methods:
get(string $url, array $params = [])— a GET request.$paramsare appended to the query string. Returns the response body (string).post(string $url, mixed $params = null)— a POST request.$paramsare sent in the request body. Returns the response body (string).create()— return a client for several requests that are executed in parallel.
If the response code is anything other than 200, get() and post() throw Tereta\Curl\Exceptions\Error.
Examples
Simple requests:
use Tereta\Curl\Client;
$client = new Client();
// GET with parameters (?page=2)
$html = $client->get('https://example.com', ['page' => 2]);
// POST with a request body
$response = $client->post('https://example.com/api', ['name' => 'Alex']);
Parallel requests via create():
$service = (new Client())->create();
$first = $service->request('https://example.com/one');
$second = $service->request('https://example.com/two');
// both requests run at the same time
$service->execute();
$bodyOne = $first->getResponse()->getBody();
$bodyTwo = $second->getResponse()->getBody();
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-07-12