PHPackages                             maksymsemenykhin/yii2-httpclient - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. maksymsemenykhin/yii2-httpclient

ActiveExtension[HTTP &amp; Networking](/categories/http)

maksymsemenykhin/yii2-httpclient
================================

Yii2 http client implementation based on Guzzle library

1.3(8y ago)0241GPL-v3PHPPHP &gt;=5.4.0

Since Mar 31Pushed 8y ago1 watchersCompare

[ Source](https://github.com/MaksymSemenykhin/yii2-httpclient)[ Packagist](https://packagist.org/packages/maksymsemenykhin/yii2-httpclient)[ RSS](/packages/maksymsemenykhin-yii2-httpclient/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (5)Versions (9)Used By (1)

Yii2 HTTP client
================

[](#yii2-http-client)

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

[](#installation)

Recommended way to install this extenstion is through Composer:

```
php composer.phar require MaksymSemenykhin/yii2-httpclient:~1.1 --prefer-dist
```

Configuration
-------------

[](#configuration)

Add this lines to your config file:

```
...
'components' => [
	'httpclient' => [
		'class' =>'MaksymSemenykhin\httpclient\Client',
		'detectMimeType' => true, // automatically transform request to data according to response Content-Type header
		'requestOptions' => [
		    // see guzzle request options documentation
		],
		'requestHeaders' => [
		    // specify global request headers (can be overrided with $options on making request)
		],
	],
],
...
```

Basic usage
-----------

[](#basic-usage)

Performing HTTP GET request with mime type detection:

```
// Result is html text
$text = Yii::$app->httpclient->get('http://httpbin.org/html');

// Result is SimpleXMLElement containing parsed XML
$xml = Yii::$app->httpclient->get('http://httpbin.org/xml');

// Result is parsed JSON array
$json = Yii::$app->httpclient->get('http://httpbin.org/get');
```

You can disable this behavior by specifying `$detectMimeType` option to whole component or single call

```
// Result is Guzzle `Response` object
$text = Yii::$app->httpclient->get('http://httpbin.org/xml', [], false);
```

Make request with custom options:

```
$text = Yii::$app->httpclient->get('http://httpbin.org/xml', [
    'proxy' => 'tcp://localhost:8125'
]);
```

Read more about this options in [Guzzle 6 documentation](http://guzzle.readthedocs.org/en/latest/request-options.html)

HTTP methods
------------

[](#http-methods)

You can make request with several ways:

1. Call shortcut method (`get()`, `post()`, `put()`, `delete()`, etc.)
2. Call `request()` method

All shortcut methods has the same signature except `get()`:

```
// Synchronous GET request
Yii::$app->httpclient->get(
    $url, // URL
    [], // Options
    true // Detect Mime Type?
);

// Synchronous POST (and others) request
Yii::$app->httpclient->post(
    $url, // URL
    $body, // Body
    [], // Options
    true // Detect Mime Type?
);

// Asynchronous GET request
Yii::$app->httpclient->getAsync(
    $url, // URL
    [] // Options
);

// Asynchronous POST (and others) request
Yii::$app->httpclient->postAsync(
    $url, // URL
    $body, // Body
    [] // Options
);
```

> **NOTE**: you still can make a GET request with body via `request()` function

Asynchronous calls
------------------

[](#asynchronous-calls)

To make an asynchronous request simly add `Async` to end of request method:

```
// PromiseInterface
$promise = Yii::$app->httpclient->postAsync('http://httpbin.org/post');
```

> **NOTE**: mime type detection is not supported for asynchronous calls

Read more about asynchronous requests in [Guzzle 6 documentation](http://guzzle.readthedocs.org/en/latest/quickstart.html#async-requests)

Request body
------------

[](#request-body)

Types you can pass as a body of request:

1. **Arrayable object** (ActiveRecord, Model etc.) - will be encoded into JSON object
2. **Array** - will be sent as form request (x-form-urlencoded)

Any other data passed as body will be sent into Guzzle without any transformations.

Read more about request body in [Guzzle documentation](http://guzzle.readthedocs.org/en/latest/request-options.html#body)

Appendix
--------

[](#appendix)

Feel free to send feature requests and fix bugs with Pull Requests

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~143 days

Total

7

Last Release

3249d ago

Major Versions

0.3 → v1.02016-03-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f2de0088773baffaa2ece818d09268218560b63eecfb2bf2b6aea14c77364ab?d=identicon)[ftlmars](/maintainers/ftlmars)

---

Top Contributors

[![AnatolyRugalev](https://avatars.githubusercontent.com/u/1397674?v=4)](https://github.com/AnatolyRugalev "AnatolyRugalev (18 commits)")[![MaksymSemenykhin](https://avatars.githubusercontent.com/u/10046424?v=4)](https://github.com/MaksymSemenykhin "MaksymSemenykhin (5 commits)")[![davidjeddy](https://avatars.githubusercontent.com/u/6232455?v=4)](https://github.com/davidjeddy "davidjeddy (1 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/maksymsemenykhin-yii2-httpclient/health.svg)

```
[![Health](https://phpackages.com/badges/maksymsemenykhin-yii2-httpclient/health.svg)](https://phpackages.com/packages/maksymsemenykhin-yii2-httpclient)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.9M6.8k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[guzzlehttp/guzzle-services

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

25711.0M189](/packages/guzzlehttp-guzzle-services)

PHPackages © 2026

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