PHPackages                             olegv9/http-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. olegv9/http-client

ActiveLibrary

olegv9/http-client
==================

Small cURL wrapper

3.0.4(5y ago)112MITPHP

Since Mar 31Pushed 5y agoCompare

[ Source](https://github.com/OlegV9/http-client)[ Packagist](https://packagist.org/packages/olegv9/http-client)[ RSS](/packages/olegv9-http-client/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (6)Used By (0)

Installation
------------

[](#installation)

```
composer require olegv9/http-client

```

Usage
-----

[](#usage)

### Setup:

[](#setup)

```
use HttpClient\HttpClient;

$http = new HttpClient();
```

### HTTP-methods:

[](#http-methods)

```
$url = 'https://example.com';

$response = $http->get($url)->text();
$response = $http->post($url, ['some' => 'data'])->text();
$response = $http->put($url, ['some' => 'data'])->text();
$response = $http->delete($url, ['some' => 'data'])->text();
```

### Response handling:

[](#response-handling)

```
$text	= $http->get($url)->text();	//raw text
$object	= $http->get($url)->json();	//json_decode() applied
$array	= $http->get($url)->json(true);	//json_decode(true) applied
```

### Methods:

[](#methods)

```
$res = $http->get($url);

$res->text();	//see above
$res->json();	//see above

//status code (200, 403, etc)
$httpCode = $res->code();

//sending request error (network failure, invalid URL, etc)
$error = $res->error();

//last URL after redirect chain (CURLINFO_EFFECTIVE_URL)
$lastUrl = $res->getUrl();

//response header
$header = $res->getHeader('Content-Type');

//all response headers list
$allHeaders = $res->getAllHeaders();

//request time
$time = $res->time();
```

### Options

[](#options)

Опции запроса передаются в виде ассоциативного массива во 2-м параметре в GET-запросе и в 3-м - в остальных

Доступные опции:

- **type** - тип запроса ("json", "urlencoded", "multipart"). По умолчанию "urlencoded"
- **followRedirects** - нужно ли делать перенаправления. По умолчанию - true
- **maxRedirects** - макс. количество перенаправлений. По умолчанию - 10
- **ignoreSslErrors** - игнорить поломаный SSL. По умолчанию - false
- **timeout** - таймаут в сек. По умолчанию - 40
- **auth** - basic-авторизация в формате "login:password"
- **headers** - ассоц. массив заголовков (см. пример ниже)
- **curlOpts** - сырые опции для curl'а

Примеры:

```
//авторизация + заголовки
$opts = [
    'auth' => 'admin:NgjrP4n',
    'headers' => [
        'X-Some-Header' => 'OK'
    ]
];
$http->get($url, $opts);

//Отправка JSON'а
$data = [
    'site' => 'somesite.com',
    'se' => 197,
    'prim' => true
];
$opts = [
    'timeout' => 10,
    'type' => 'json'
];
$http->post($url, $data, $opts);
```

### Multicurl

[](#multicurl)

Пример:

```
$urls = [
    'http://example.com',
    'http://example.com/page',
    'http://example.org'
];

$opts = ['timeout' => 10];
$results = $http->multiGet($urls, $opts);
//или
//$results = $http->multiRequest('POST', $urls, $postData, $opts);

foreach ($results as $res) {
    echo $res->text();	//текст ответа. Доступные также все методы, описанные выше
}
```

Массив может состоять как из URL'ов, так и из ассоциативного массива с настройками:

```
$urls = [
    'http://example.com',
    'http://example.com/send',
    [
        'method' => 'POST',
        'url' => 'http://example.net',
        'data' => ['a' => 123],
        'opts' => ['timeout' => 20]
    ],
    'http://example.org'
];
$http->multiRequest('GET', $urls);
```

### License

[](#license)

[MIT](https://opensource.org/licenses/MIT)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

1866d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc38996391f3c2ef9e402fc4f45ae4501bda3ac019f9c50f64459cafa37044d2?d=identicon)[olegv9](/maintainers/olegv9)

---

Top Contributors

[![OlegV9](https://avatars.githubusercontent.com/u/64600560?v=4)](https://github.com/OlegV9 "OlegV9 (1 commits)")

### Embed Badge

![Health badge](/badges/olegv9-http-client/health.svg)

```
[![Health](https://phpackages.com/badges/olegv9-http-client/health.svg)](https://phpackages.com/packages/olegv9-http-client)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
